Replace in compile

I’m trying to replace “soft” line breaks in various inspector fields with just a space. What I mean by soft line breaks is something created when Ctrl Opt Enter is used within an inspector field- I may be using the wrong term so I figured it important to define.

This is for an TXT file compile that I then import into excel. In compile, in the replacements tab, I’ve tried using regex \r \n and \r\n with the regex button check to no avail. Are there any other suggestions (asci code, maybe?) on accomplishing this? I’m running Scrivener V 3.3.6 on a Macbook Pro M1, Sonoma 14.3.1. Thanks!

You could try to use a normal replacement (not a regex), in which, if you can’t type it in, you’d copy paste your “soft line break” in, from your project, and replace it with a space.

You just need to fetch it first, with the compile panel closed.

Oh, I had such hopes for this. It seems so logical, but unfortunately it didn’t work.

Still open to any other suggestions!

That should be working, and in fact in the Mac version there is no need to go and find one and copy and paste, you have access to the Edit ▸ Insert ▸ Line Break (the official name for it) while typing in the Replacement fields.

But if that still isn’t working, you could try copying and pasting this into the Replacements pane. I set it to replace to two dots to make it easier to test with and see, but that part should be easy and safe to fix:

You can’t see it, but the 0x2028 control character you want (I think!) should be in there:

<Replacements>
<Replacement>
    <Replace><![CDATA[ ]]></Replace>
    <With><![CDATA[..]]></With>
</Replacement>
</Replacements>

Hmm, it might not be. If it doesn’t go through browsers and all that, then this has it.

replacement.txt (130 Bytes)

1 Like

Neither of those worked (code insert or the Edit>Insert>Line break). I think my problem lies is one of two areas - I’m not looking to replace a Line break as defined by Edit>Insert>Line break as Opt Cmd Enter - but I’m looking to replace a Ctrl>Opt> Enter type line break that allows me to see separate lines within Inspector field. The second thing I wonder about is if the compile>replace works in inspector custom fields?

I’m not sure what Ctrl-Opt-Return would be adding, actually. I figured you had customised the shortcut from its default or something. For me, that just inserts a regular break, with no modifiers (so on my system, in effect Ctrl is ignored, as Opt-Return is all you need to insert a break into a field that would otherwise terminate editing or submit an OK button on Return).

The second thing I wonder about is if the compile>replace works in inspector custom fields?

Ooooh, that’s another twist, yes. I was thinking regular old Document Notes, but must have missed you meant inserting custom fields via a placeholder. Those indeed sometimes can evade Replacements. Not for lack of trying, but there is complicated interplay between replacements and placeholders, so that replacements can, in some cases, create placeholders, which then later get processed into text. There is in theory another replacement run that happens after that, but it gets really thorny avoiding loop conditions and such and not everything works well.

Perhaps you could run a replacement once there, instead ?
Or is it that it creates unwanted cells ?

Or use an intermediary text editor, compiling to RTF ?

Yeah, or if you want to roll your sleeves up with sed or perl on the command line, the Plain-Text compile file type does have a Processing compile format pane after all. :slight_smile: That is precisely what I do when I need to make a “replacement” that is evasive like this one might be. It works because it runs after the .txt file is finalised, and is thus complete from Scrivener’s perspective.

1 Like

Yep, I’m there. If I use ATOM to “join lines” it works. Thanks to both of you! :pray:

1 Like