• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Finding/Replacing Beginning or End of a Line

Community Beginner ,
Mar 11, 2018 Mar 11, 2018

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?

Views

3.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Mar 12, 2018 Mar 12, 2018

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

...

Votes

Translate

Translate
Mentor ,
Mar 11, 2018 Mar 11, 2018

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…

EndOfLine.PNG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 12, 2018 Mar 12, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 13, 2018 Mar 13, 2018

Copy link to clipboard

Copied

Nice one!

It doesn't work until I saved the script in UTF-8.

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2018 Mar 13, 2018

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!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

LATEST

This is a very neat solution. Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines