How do I delete blank lines using search and replace
How do I delete blank lines using search and replace
MacBook Pro, OS X Yosemite (10.10), 8 GB RAM
How do I delete blank lines using search and replace
MacBook Pro, OS X Yosemite (10.10), 8 GB RAM
Lets assume Pages v5.5.3 on your Yosemite. From your Pages View menu, Show Invisibles. This will show the hard and soft returns that appear to comprise those blank lines in your document. Let's deal with the hard returns first. By example the following has a single blank line between each character:
Select the pilcrow below the A, and the one immediately behind the A. Then, in you would press command+E to use these two pilcrow character selections for your Find. The command+E is a shortcut from the Edit ▸ Find ▸ Use Selection for Find menu item. Now, just select the pilcrow behind the A, and choose Edit ▸ Find ▸ Use Selection for Replace. In short, we are replacing two pilcrow with a single pilcrow that will collapse the blank lines.
Press command+F, or Edit ▸ Find ▸ Find… , and your Find and Replace fields are pre-filled from the previous paragraph. Your find field will also report how many double-pilcrow matches it found. Then click Replace All. The result looks like the following:
What if you have a mixture of hard (pilcrow) and soft (carriage ↵ ) returns that looks like the following:
You would perform paragraph two again, this time selecting the carriage return behind the A, and the next pilcrow, followed by command+E. Then just select a single pilcrow for your replace sequence. Command+F, and replace all. This will leave you with the following, and for that extra hard (pilcrow) return in it, you now know how to remove it too.
Lets assume Pages v5.5.3 on your Yosemite. From your Pages View menu, Show Invisibles. This will show the hard and soft returns that appear to comprise those blank lines in your document. Let's deal with the hard returns first. By example the following has a single blank line between each character:
Select the pilcrow below the A, and the one immediately behind the A. Then, in you would press command+E to use these two pilcrow character selections for your Find. The command+E is a shortcut from the Edit ▸ Find ▸ Use Selection for Find menu item. Now, just select the pilcrow behind the A, and choose Edit ▸ Find ▸ Use Selection for Replace. In short, we are replacing two pilcrow with a single pilcrow that will collapse the blank lines.
Press command+F, or Edit ▸ Find ▸ Find… , and your Find and Replace fields are pre-filled from the previous paragraph. Your find field will also report how many double-pilcrow matches it found. Then click Replace All. The result looks like the following:
What if you have a mixture of hard (pilcrow) and soft (carriage ↵ ) returns that looks like the following:
You would perform paragraph two again, this time selecting the carriage return behind the A, and the next pilcrow, followed by command+E. Then just select a single pilcrow for your replace sequence. Command+F, and replace all. This will leave you with the following, and for that extra hard (pilcrow) return in it, you now know how to remove it too.
Pressing command-e on a selection does absolutely nothing that you can see, but it does advance populate the Find field before you launch the Find interface. You then must select a replacement character, using one of these:
Sometimes, it is beneficial to select Whole Words from the Find panel gear icon.
It is insufficient to tell us that something did not work. Tell us a story about what you want to achieve with Find/Replace, what specifically is/are the individual find and replace character(s). Help us to help you.
This was really helpful — the issue was driving me nuts, as each day I have to copy from the web and paste into Pages and remove (until now, manually) hundreds of paragraph breaks. I knew how to show invisibles, and I was trying manually to copy them and paste into the Find/Replace box, but this just doesn't work. So counter-intuitive. I really appreciate the help, and am surprised at Apple. It took me a long time to track down this thread. Thanks.
Kitten is correct. 5.6.2 only marginally allows for the copy and replacement of invisibles. I have a 1,300 page document and am unable to use Find / Replace, Copy / Paste Styles, Create a Style etc. to deal with the removal of simple carriage returns en masse having converted HTML to plain text.
It seems incredibly backwards to progressively limit this feature so I will assume that nobody in this thread knows where Apple hid the solution which is so often the case... I am able to find and delete one line at a time, but perhaps you missed the 1,300 pages bit! Why not allow 'Styles to recognize carriage returns?
The trouble is that there are returns inside the paragraphs as well the need to add hard returns between paragraphs. I suspect adding a return en masse is impossible, but the simple internal return deletions MUST be possible even if only one paragraph at a time, although, did I mention 1,300 pages, 1,340 to be precise?
A solution would be appreciated.
So what is the pattern?
A hard return at the end of each line, or a soft return (a line feed), which needs to be replaced with a space?
Two returns at the end of each paragraph?
If you have this then it can be fixed but you also probably need to do a whole lot more cleaning up of the text. Bad spacing, punctuation, tabs, capitalisation etc.
No way would I do it in Pages simply because it is not built for large amounts of text.
Where has this text come from?
What format is it in?
What is the end result you wish to achieve?
Peter
Soft Returns at the end of each line. I'm manually adding a hard return between paragraphs currently.
I have tried Clean Text, Libre Office and Word with less success than Pages.
The text was originally HTML and has been substantially cleaned up. I made a short screenview video but the insert video directly above in this window is greyed....
End result is a legible document with proper paragraph spacing and preferably no spaces, as well a space between major paragraphs (which I suspect must be achieved manually).
Thanks Peter...
Link to screencast video on Dropbox. It shows the only method I currently know in Pages to eliminate Soft Returns (one line at a time).
https://www.dropbox.com/s/lk28jqx1kjpejle/Apple%20Return%20Issue.mov?dl=0
You may have made extra work for yourself. But you can go back to an original version.
I use TextWrangler or BBedit usually, even TextEdit. LibreOffice would be fine.
NisusWriter is also excellent as it allows you to use GREP.
First step is always to find and mark the paragraph returns, which are usually 2 returns. Mark those with a unique replacement, I usually use <#>.
Then find and replace all the soft returns, replacing those with word spaces. Then go back to find <#> and replace that with a return.
You will need also to search and replace on multiple spaces, spaces inside brackets, before punctuation, tabs and after returns, multiple tabs, multiple returns etc.
Never, EVER do things manually, you will usually only make matters worse.
Peter
When you say, "First step is always to find and mark the paragraph returns, which are usually 2 returns. Mark those with a unique replacement, I usually use <#>," I presume you are referring to a specific application with this feature capability. I am unfamiliar with replacing text nor does the value of doing this make sense to me. If I am able to replace a specific condition with a symbol, why not replace it with the format I seek instead? Please could you clarify?
Thanks
I can't see the text, but it sounds like you may have messed up the original in your attempts to clean it up.
Normally you can differentiate between line feeds and returns or get them from formatting habits.
Also it usually pays not to work directly from HTML but from the text as shown in a browser, which is cleaner when copied and can be pasted without formatting.
I would be using a TextEditor such as BBedit or TextWrangler, both of which use GREP, for cleaning up the text.
The current version of Pages is awful for Find and Replace. Pages '09 is better but still requires multiple manual sweeps.
Peter
Skyeword wrote:
When you say, "First step is always to find and mark the paragraph returns, which are usually 2 returns. Mark those with a unique replacement, I usually use <#>," I presume you are referring to a specific application with this feature capability. I am unfamiliar with replacing text nor does the value of doing this make sense to me. If I am able to replace a specific condition with a symbol, why not replace it with the format I seek instead? Please could you clarify?
Thanks
No. It is simply a temporary marker, in any old App, to distinguish the ends of paragraphs from line feeds.
First sweep you find the ends of paragraphs (usually typed with 2 returns), which you replace with the marker that can be anything but <#> is unique.
Second sweep you replace all the single returns at the ends of lines with single word spaces. If you hadn't replaced the double end returns, those would also become word spaces.
Third sweep you find all the <#> markers and replace them with single returns.
You need a lot more clean up usually.
Multiple wordspaces and tabs, spaces before punctuation and at the beginnings of paragraphs, etc.
It's basic systematic logic. Look for patterns, bad habits, and replace them in either one or two steps.
Peter
So you've made an assumption and told me what not to do though not offered any further insights on what your words mean? Why would you do that? Padding your stats? Was your first answer from a user guide though not from personal experience? If I wanted to flatline 1,300 pages and turn it all to simple text, I cold easily have done that. The softwares you mention are primarily for HTML and GREP is some cryptic tool for folks I presume that interact with HTML formatted text. I looked it up on Wiki and still do not understand how that solves my specific problem.. I've been using Macs professionally since 1989 and from this vast experience I know enough to use Simple Text to clear all formatting, but this is not what I seek and I made that clear. 1,300 pages of text that requires individual formatting is far more work than manually deleting soft returns of formatted text. Jeeeez man!
What version of Pages?
Peter
Yep, that works fine; just seems like a huge complication of what was a straightforward procedure.
Apple got it wrong. They should have named it PITA, not Pages. 😉
How do I delete blank lines using search and replace