Automatically removing linebreaks in LibreOffice Writer

libreoffice-writer

Often I find that I copy text from a gedit (linux) text editor document into a word processor like LibreOffice Writer. Of course I have hard linebreaks coded into the text.

How can I do a search and replace to reflow the text in LibreOffice Writer? In other words, I need the linebreaks removed.

Edit: Since it was suggested, I will add that I did tick regular expressions and being an old programmer I did use \n just in case it has any meaning for LibreOffice. The search key was not found when I opted for the find-and-replace.

Best Answer

  1. In the Edit > Find and Replace dialog, tick "Use regular expressions", put "\n" in the 'search for' box, nothing in the replace with box, click Replace all. This removes line breaks that you can insert with Shift+Enter (manual line breaks). Here's a link to LibreOffice documentation on regular expressions.
  2. LibreOffice Writer can't replace paragraph breaks by default. Use the AltSearch add-on for OpenOffice, as it also works with LibreOffice.
  3. To do the paste-and-remove-linebreaks automatically, you can try recording a macro (help.libreoffice.org/Common/Macro), just paste and perform the replace and have LibreOffice record them in a macro.
Related Question