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 19: Line 19:
 
:Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.
 
:Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.
   
;<code>:s/foo/bar/g</code>
+
;<code>:%s/foo/bar/g</code>
 
:Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
 
:Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
   
  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