Difference between revisions of "Extended Replace"
(Created page with '<noinclude>{{manversion|5.3.0.2|feature}}__NOTOC__</noinclude> ====Extended Replace.. (Alt+Ctrl+R)==== Searches for all occurrences of a specified {{field|Extended Replace|Find …') |
|||
Line 1: | Line 1: | ||
− | <noinclude>{{manversion| | + | <noinclude>{{manversion|6.0.0.16|feature}}__NOTOC__</noinclude> |
====Extended Replace.. (Alt+Ctrl+R)==== | ====Extended Replace.. (Alt+Ctrl+R)==== | ||
Searches for all occurrences of a specified {{field|Extended Replace|Find what}} phrase within the selection and replaces them with {{field|Extended Replace|Replace with}} phrase. | Searches for all occurrences of a specified {{field|Extended Replace|Find what}} phrase within the selection and replaces them with {{field|Extended Replace|Replace with}} phrase. | ||
− | + | By default, the search is {{defined|case insensitive}}. {{field|Extended Replace|Match case}} option can be used to make the search {{defined|case sensitive}}. | |
− | + | {{field|Extended Replace|Whole words}} option can be used to restrict the search to only those matches, which start and end at word boundaries. Note that a match itself might contain {{defined|non-word characters}}, since only the boundaries of the match are probed. Therefore, the last character before the match and the first character after the match may not be {{defined|word characters}}; while the first character and the last character of the match must be {{defined|word characters}}. | |
− | + | {{field|Extended Replace|RegExps}} option can be used to turn the {{feature|Regular expressions}} engine on. When {{feature|Regular expressions}} are enabled, {{field|Extended Replace|Find what}} is parsed as a ''regular expression pattern''. See chapter [[Regular expressions]] for more details on supported regular expressions syntax. | |
− | + | Note: Invalid or faulty patterns result in tool refusing to work until the pattern is corrected. | |
− | + | {{field|Extended Replace|Mimic case}} option can be used to {{defined|mimic character case}} of matches upon replacing. This option individually converts {{defined|character case}} of the replacement string upon each match. The conversion is done upon actual replacing (i.e. after the replacement string is prepared for the match) and the conversion takes only {{defined|character case}} of the match into account. Therefore, the {{defined|mimic case}} may result in different {{defined|character case}} for each match. If the tool cannot decide how to {{defined|mimic case}} of a match, it leaves the replacement intact, giving the user a chance to specify one special {{defined|mixed case}} replacement. | |
− | Note: This tool is prefered to the standard {{button|Find Bar|Replace All}} mechanism from the {{feature|Find Bar}} in many cases. Its search is done in more feasible way and the replacing routine works much | + | {{tip}} The {{defined|mimic case}} option only recognizes the ''basic'' types of {{defined|character case}}, i.e. {{defined|lower case}}, {{defined|upper case}}, {{defined|word capitals}}, {{defined|first capitals}}. Everyting else is considered {{defined|mixed case}} and the tool does not try to convert case of the replacement. This can be utilized to specify ''one'' {{defined|mixed case}} version of the replacement. Consider you need to replace {{string|OneHalf}} with {{string|SlovakBomber}}, but want to use the {{defined|mimic case}} to automatically replace {{string|onehalf}} with {{string|slovakbomber}} and {{string|ONEHALF}} with {{string|SLOVAKBOMBER}}. Using {{string|SlovakBomber}} as a replacement will do the trick. |
+ | |||
+ | Note: Newlines and Tab characters can be used in {{field|Extended Replace|Find what}} and {{field|Extended Replace|Replace with}} fields freely. Moreover, each newline from the {{field|Extended Replace|Find what}} field matches any kind of newline in the document (Win/Unix/Mac). Each newline from the {{field|Extended Replace|Replace with}} field is converted to the current newline type (as shown in the {{feature|Status Bar}} for example) upon replacing. | ||
+ | |||
+ | Note: This tool is prefered to the standard {{button|Find Bar|Replace All}} mechanism from the {{feature|Find Bar}} in many cases. Its search is done in more feasible way and the replacing routine works much faster and uses less resources. Furthermore, the selection ensures, that the replacing is done only in the desired part of the text. And finally, one {{feature|Undo}} step covers all replacements together, instead of grouping many small separate replacements. Although this may not be directly apparent, it is incomparably better to have one big {{feature|Undo}} step instead of too many small {{feature|Undo}} steps. On the other hand, if you expect only a handful of matches and replacements in a big big document, the <i>old good</i> looping {{button|Find Bar|Replace All}} routine might come more handy. |
Revision as of 20:48, 7 May 2011
Control page Control:feature:Extended Replace
Extended Replace.. (Alt+Ctrl+R)
Searches for all occurrences of a specified Find what phrase within the selection and replaces them with Replace with phrase.
By default, the search is case insensitive
. Match case option can be used to make the search case sensitive
.
Whole words option can be used to restrict the search to only those matches, which start and end at word boundaries. Note that a match itself might contain non-word characters
, since only the boundaries of the match are probed. Therefore, the last character before the match and the first character after the match may not be word characters
; while the first character and the last character of the match must be word characters
.
RegExps option can be used to turn the Regular expressions engine on. When Regular expressions are enabled, Find what is parsed as a regular expression pattern. See chapter Regular expressions for more details on supported regular expressions syntax.
Note: Invalid or faulty patterns result in tool refusing to work until the pattern is corrected.
Mimic case option can be used to mimic character case
of matches upon replacing. This option individually converts character case
of the replacement string upon each match. The conversion is done upon actual replacing (i.e. after the replacement string is prepared for the match) and the conversion takes only character case
of the match into account. Therefore, the mimic case
may result in different character case
for each match. If the tool cannot decide how to mimic case
of a match, it leaves the replacement intact, giving the user a chance to specify one special mixed case
replacement.
Tip: The mimic case
option only recognizes the basic types of character case
, i.e. lower case
, upper case
, word capitals
, first capitals
. Everyting else is considered mixed case
and the tool does not try to convert case of the replacement. This can be utilized to specify one mixed case
version of the replacement. Consider you need to replace OneHalf with SlovakBomber, but want to use the mimic case
to automatically replace onehalf with slovakbomber and ONEHALF with SLOVAKBOMBER. Using SlovakBomber as a replacement will do the trick.
Note: Newlines and Tab characters can be used in Find what and Replace with fields freely. Moreover, each newline from the Find what field matches any kind of newline in the document (Win/Unix/Mac). Each newline from the Replace with field is converted to the current newline type (as shown in the Status Bar for example) upon replacing.
Note: This tool is prefered to the standard Replace All mechanism from the Find Bar in many cases. Its search is done in more feasible way and the replacing routine works much faster and uses less resources. Furthermore, the selection ensures, that the replacing is done only in the desired part of the text. And finally, one Undo step covers all replacements together, instead of grouping many small separate replacements. Although this may not be directly apparent, it is incomparably better to have one big Undo step instead of too many small Undo steps. On the other hand, if you expect only a handful of matches and replacements in a big big document, the old good looping Replace All routine might come more handy.