Using Find and Replace

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 04:35, 24 November 2006 (edit)
Sardisson (Talk | contribs)
(Sample Searches - botlangbar fr)
← Previous diff
Revision as of 18:08, 3 December 2006 (edit) (undo)
Sardisson (Talk | contribs)
(Returns/Blank Lines - yoxi's macro)
Next diff →
Line 18: Line 18:
*You cannot use <tt>^</tt> or <tt>$</tt> in the replace field to insert paragraphs - it has to be <tt>\n</tt> *You cannot use <tt>^</tt> or <tt>$</tt> in the replace field to insert paragraphs - it has to be <tt>\n</tt>
 +
 +* [[User:yoxi|yoxi]] contributes the following macro useful for reformatting text where every line ends with a return (plain text to proper paragraphs): [http://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&p=26151#26151]
=== Tabs === === Tabs ===

Revision as of 18:08, 3 December 2006

OpenOffice.org and thus NeoOffice use a somewhat convoluted Find-and-Replace syntax. This page will hopefully demystify some of the commonly-used commands.

Returns/Blank Lines

  • Search and replace of formatting characters, such as returns (paragraph ends) and tabs can only be done by using the regular expression feature. You can't paste these characters into the search and replace fields.
  • Check the "Regular Expressions" box in the Search dialog, then fill in the codes required. These are given in the online help, but the explanations are not very clear.
  • ^$ as the search term will find and select for replacement empty paragraphs, but ^$^$ does not find adjacent empty paragraphs - it returns no matches.
  • $ as the search term finds and selects for replacement all end-of-line characters, but any text$ finds and selects occurrences of any text at the end of lines, without selecting the end-of-line charter itself.
  • There is no way to replace two returns; Iannz's Find & Replace Macro will do this.
  • You cannot use ^ or $ in the replace field to insert paragraphs - it has to be \n
  • contributes the following macro useful for reformatting text where every line ends with a return (plain text to proper paragraphs): [4]

Tabs

  • \t represents a tab character. This behaves in a sane manner, as \t\t is two tabs, etc, and it is the same code in both find and replace.

Sample Searches

From amayze:

I recently complained in this post about the fact that NeoOffice regular expressions sometimes mean two different things depending where you use them, however this [in a Word .doc, "paragraph breaks" were actually represented in the file as line breaks within one giant paragraph (#$*&!@ Word...), so it's no wonder you ended up with one big mass of text after trying to strip out the whitespace] is exactly the instance when this is useful.

Try doing a search and replace.

  1. Click on "More Options..." and check the box by "Regular Expressions"
  2. Search for "\n" - which will match the line breaks in your document - and replace it with "\n" which will insert paragraph breaks in their place.
  3. Now change the search term to "^$" and the replace to "" (nothing) and you will be able to remove of the blank paragraphs in between your text.

Hope that helps.[5]


This article in other languages: Français
Personal tools