VIM

From GreyWiki
Jump to: navigation, search

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
// vim:ft=php
:set ff=unix
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox