Adding newlines with find and replace

(Galen Menzel) #1

Is there a way to encode a newline into the TBX editor’s find and replace text field? I.e., if I wanted to add a newline after every occurrence of “foo”? Or do I have to resort to action code to do this?

(Mark Anderson) #2

\n is the normal line end/break marker. This works for me:

$Text = $Text.replace("\n","\n\n");

Note that you need to explicitly pass the result of $Text.replace() back as the new value of $Text. Just calling the replace function alone won’t affect the existing test.

If you wanted to only double space after paragraphs ending ‘foo’, then use:

$Text = $Text.replace("foo\n","foo\n\n");

(Galen Menzel) #3

Hi Mark — thanks for the reply.

Can you do this with the find-and-replace dialog box? I’m talking about this thing:

(Mark Anderson) #4

(testing in v7.5.0b318) It seems not. For a task of this type using ‘invisible’ characters, I’d generally use a stamp (or other action context) as per my previous answer.

Still, I take the point. I think you may be about to make a feature suggestion!

(Pat Maddox) #5

Yep, type alt-return in the replace field to insert a newline.

(Galen Menzel) #6

Ah, you mean like with basically every other text field in the entire application?