Vim Tips Wiki

Editing

Search and replace

1
  • The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit. If you are undoing an edit that is …
Latest revision Your text
Line 74: Line 74:
 
:<code>\t</code> is tab, <code>\s</code> is whitespace (space or tab)
 
:<code>\t</code> is tab, <code>\s</code> is whitespace (space or tab)
 
:<code>\n</code> is newline, <code>\r</code> is CR (carriage return = Ctrl-M = ^M)
 
:<code>\n</code> is newline, <code>\r</code> is CR (carriage return = Ctrl-M = ^M)
:After an opening <code>[</code>, everything until the next closing <code>]</code> specifies a {{help|prefix=no|/collection}}. Character ranges can be represented with a <code>-</code>; for example a letter a, b, c, or the number 1 can be matched with <code>[1a-c]</code>. Negate the collection with <code>[^</code> instead of <code>[</code>; for example <code>[^1a-c]</code> matches any character except a, b, c, or 1.
+
:After an opening <code>[</code>, everything until the next closing <code>]</code> specifies a {{help|prefix=no|/collection}}. Character ranges can be represented with a <code>-</code>; for example a letter a, b, c, or the number 1 can be matched with <code>[1a-c]</code>. Negate the collection with <code>[^</code> instead of <code>[</code>; for example <code>[^13579]</code> matches only even digits.
 
:<code>\{#\}</code> is used for repetition. <code>/foo.\{2\}</code> will match foo and the two following characters. The <code>\</code> is not required on the closing <code>}</code> so <code>/foo.\{2}</code> will do the same thing.
 
:<code>\{#\}</code> is used for repetition. <code>/foo.\{2\}</code> will match foo and the two following characters. The <code>\</code> is not required on the closing <code>}</code> so <code>/foo.\{2}</code> will do the same thing.
 
:<code>\(foo\)</code> makes a backreference to foo. Parenthesis without escapes are literally matched. Here the <code>\</code> is required for the closing <code>\)</code>.
 
:<code>\(foo\)</code> makes a backreference to foo. Parenthesis without escapes are literally matched. Here the <code>\</code> is required for the closing <code>\)</code>.
  Loading editor
Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above.

View this template