as far as I understand your task, you have text objects that contain multiple consecutive paragraph breaks (and therefore empty paragraphs) which you want to change into just single paragraph breaks.
If that applies, you may try this javascript snippet:
if (app.documents.length && app.activeDocument.selection.length) { function f(item) { if (item.typename === "TextFrame") { item.contents = item.contents.replace(/\r\n/g, "\r").replace(/[ \t]*\r(?:[ \t]*\r)+/g, "\r"); } else if (item.pageItems) { for (var i = 0; i < item.pageItems.length; i++) f(item.pageItems[i]); } } var sel = app.activeDocument.selection; for (var j = 0; j < sel.length; j++) f(sel[j]); }
We would like to follow up on your issue. Did you try the workaround suggested by our expert? Let us know if that helps. You may also want to upvote the UserVoice request shared in this post.
as far as I understand your task, you have text objects that contain multiple consecutive paragraph breaks (and therefore empty paragraphs) which you want to change into just single paragraph breaks.
If that applies, you may try this javascript snippet:
if (app.documents.length && app.activeDocument.selection.length) { function f(item) { if (item.typename === "TextFrame") { item.contents = item.contents.replace(/\r\n/g, "\r").replace(/[ \t]*\r(?:[ \t]*\r)+/g, "\r"); } else if (item.pageItems) { for (var i = 0; i < item.pageItems.length; i++) f(item.pageItems[i]); } } var sel = app.activeDocument.selection; for (var j = 0; j < sel.length; j++) f(sel[j]); }
Hi, you're right that Illustrator's Find and Replace doesn't offer a special code for paragraph returns the way InDesign does — so you can't type a code for them. The workaround is to copy the return character itself into the dialog:
1. Click into the text, place the cursor at the end of a paragraph, and press Shift + Right Arrow to select the paragraph break, then Copy.
2. Open Edit > Find and Replace and paste that break into the Find field. To collapse two returns into one, paste two paragraph breaks in Find (select two consecutive breaks in the text and copy them).
3. Copy a single paragraph break and paste it into the Change field, then click Replace All. Run Replace All again if you have three or more returns in a row, since each pass only removes one extra return.
One note: this copy-and-paste method has been reported to work on Mac, but not reliably on Windows in older versions, so if the Find field won't accept the pasted break, please let us know which platform and Illustrator version you're on.