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

Finding/Replacing Beginning or End of a Line

Community Beginner ,
Mar 11, 2018 Mar 11, 2018

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?

4.4K
Translate
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

...
Translate
Mentor ,
Mar 11, 2018 Mar 11, 2018

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

Translate
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

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

Translate
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

Nice one!

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

Thanks!

Translate
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

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

Translate
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

This is a very neat solution. Thank you!

Translate
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
New Here ,
Oct 29, 2024 Oct 29, 2024
Can you explain step by step how I should save your script to make it work in my InDesign? I don't know anything about programming, JavaScript, etc. I pasted your code to GitHub.com and saved the file, but after uploading it to the script folder it doesn't want to work. I'm probably doing something wrong, but I don't know what...
Translate
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
LEGEND ,
Oct 30, 2024 Oct 30, 2024
LATEST
Translate
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