Friday 26 October 2012

Vim find and replace command

How to search and replace entries in vim?

vim find and replace command looks as follows:

:%s/one/two/g
Looks for 'one' and changes it to 'two' in the whole file

:%s/one/two/gc
Searches strings 'one' and replaces with 'two'. 'c' option means that vim is asking for confirmation first.

:%s/one\/two/gc
This command is changing 'one' to 'two' only if word 'one' matches completely

:%s/one/two/gi
Substitutes 'one' with 'two' with case insensitive option

:%s/one/two/gI
Find and replaces 'one' with 'two' with case sensitive option

Example of find and replace command in vim text editor.



No comments:

Post a Comment