Copy link to clipboard
Copied
Does anyone know how to find the beginning or end of a line in InDesign (NOT the beginning or end of a paragraph, and NOT a forced line break) and replace it with a forced line break or a paragraph break.
Here's my situation:
I have many, many irregular text frames with 5,000+ names in one long paragraph. The complete names are separated by bullets. The complete names are held together by nonbreaking spaces, and the bullets have spaces before them to that the lines can wrap.
What I need to do is identify any bullet that comes at the beginning of a line (wrapped automatically) and replace that with a forced line break.
Example
I need to go from this (using the text character symbols):
Jane^sSmith •^sJJohn^sSmith •^sKarl^sSmith
•^sLarry^sSmith •^sMike^sSmith •^sNed^sSmith
•^sOlive^sSmith •^sPaul^sSmith •^sRob^sSmith
To this:
Jane^sSmith •^sJJohn^sSmith •^sKarl^sSmith^n
Larry^sSmith •^sMike^sSmith •^sNed^sSmith^n
Olive^sSmith •^sPaul^sSmith •^sRob^sSmith^n
I can't find a GREP solution or a Text find/replace solution. Only thing I can figure out is to do it by hand. Any great ideas out there?
Hi,
Even if it's simple to do it here with Grep:
One single para! … So include 2 temporary nested line styles [[none] char styles called "X" and "Y"] to isolate each line and run 2 regex as:
1/
Find: (?<!.)~8~s
Replace by: \n
Find format: "X"
2/
Find: (?<!.)~8~s
Replace by: \n
Find format: "Y"
… I prefer these 2 [JS] code lines! … Just place the cursor in the para and run them!
...var myLines = app.selection[0].paragraphs[0].lines.everyItem().getElements(), L = myLines.length;
while (L--) if ( myLines
.characte
Copy link to clipboard
Copied
Unfortunately, there’s no specific GREP code for 'end of line' in InDesign layout.
FWIW, exporting to pdf has this side effect (usually unwanted) of adding hard returns at the end of every line…
Copy link to clipboard
Copied
Hi,
Even if it's simple to do it here with Grep:
One single para! … So include 2 temporary nested line styles [[none] char styles called "X" and "Y"] to isolate each line and run 2 regex as:
1/
Find: (?<!.)~8~s
Replace by: \n
Find format: "X"
2/
Find: (?<!.)~8~s
Replace by: \n
Find format: "Y"
… I prefer these 2 [JS] code lines! … Just place the cursor in the para and run them!
var myLines = app.selection[0].paragraphs[0].lines.everyItem().getElements(), L = myLines.length;
while (L--) if ( myLines
.characters.itemByRange(0,1).contents == "• " ) myLines .characters.itemByRange(0,1).contents = "\n";
Using "para line" Javascript feature! … So, simply search the two first chars of each line and replace them by a soft-return if they are: "• "
Best,
Michel, from FRIdNGE
Copy link to clipboard
Copied
Nice one!
It doesn't work until I saved the script in UTF-8.
Thanks!
Copy link to clipboard
Copied
Thank you so much!! I figured that there must be a way to do this—it will save a huge amount of time. I tried the GREP and it worked perfectly. Very clever, using the line styles to isolate each line.
I have never used javascript in InDesign, but I'll try to figure that out.
Again, THANK YOU!!
Copy link to clipboard
Copied
This is a very neat solution. Thank you!