VIM
From GreyWiki
- Search and replace!
Replace every occurrence of the word foo with bar on current line:
:s/foo/bar/g
Replace every occurrence of the word foo with bar in the whole file:
:%s/foo/bar/g
The same as above, but ignore the case of the pattern you want to substitute. This replaces foo, FOO, Foo, and so on:
:%s/foo/bar/gi
Confirm every substitution:
:%s/foo/bar/gc
For each line on the file, replace the first occurrence of foo with bar and confirm every substitution:
:%s/foo/bar/c
- To force PHP-style syntax highlighting in a file that doesn't have the .php extension, include the following somewhere within a <?php ... ?> section:
// vim:ft=php
- To change file format from DOS-style to UNIX-style, from inside VIM issue this command:
:set ff=unix