New-line search & replace in OpenOffice.org Writer
March 25, 2010Linux User & Developer has an article by Sukrit Dhandania on optimising (UK spelling
) OpenOffice.org. An anonymous user left a comment claiming that he had opened 10 tickets regarding basic new line search-and-replace.
<quote>
10 times my ticket was closed in 10 years telling me its not important feature that needs attention.
</quote>
I remembered that OpenOffice.org Writer has a regular expression option in the search dialog:
To help you see this procedure in action, I created the Google document below from a GMail message:
Since GMail put in the new line character between lines, and two new-line characters between paragraphs, this would be a mess to edit.
First thing to do is look for the double occurrences of the line feed (or new line, or spaces, if you prefer) that separate paragraphs, then change those to a sequence of characters that couldn’t possibly appear in the text. For this particular document, I chose ‘NewParagraphHolder’:
The regular expression for a line feed is \n. I did this first instead of the single line breaks between lines within a paragraph. I´ll explain this after the next step. In the meantime, here´s what the document will look like:
Next, search for the single occurrence of the line feed, and replace with a space:
If I had done this step before the search-and-replace on the double line feed, the entire document would run into one large paragraph. Try this yourself if you´re not convinced. Incidentally, that´s a space in the ¨Replace with¨ box. Here´s a screen shot of the document after that search-and-replace:
Now we´ve let OpenOffice.org Writer´s word wrap take care of putting in line feeds. Finally, I replace the end-of-paragraph character with the real end-of-paragraph, a line feed:
And my document´s happy:
Incidentally, you may notice that my single \n still created two line feeds between paragraphs. That´s because of my default style sheet, which automagically inserts an extra line after a paragraph.
Previous Comments
Thank you for the kind words. I can’t say that I’m an OpenOffice.org expert, although I *can* say that I’m pretty good at searching through and understanding the Help
I do write on some OOo feature when and as I need it. For instance, I had occasion several weeks ago to use the LOOKUP and other functions. Dunno if it’s worth a post — IOW, I’m still too lazy to do it
Although enough demand (hint, hint ) may just get me off my lazy butt.
I know how to use microsoft but not so familiar. Thanks for the information.
Posted by philwebservices at June 17, 2010, 8:06 amI keep forgetting to mention that I submitted an expanded version of this post to Free Software Magazine (http://www.freesoftwaremagazine.com). That version includes instructions on creating a macro based on this new-line search-and-replace.
Posted by Daniel Escasa at June 17, 2010, 8:40 amAll comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.





















Good thing that you made some openoffice tutorial cuz you know sometimes if I need something to tweak I don’t really know what to do.
Now, I found this blog. Thank you.
Posted by Web Oracle at June 8, 2010, 11:35 am