Jeff Roberts
RHCE #804006066322833
Vim-Fu is now iPhone and Android friendly

Check out the Vim-Fu Store!

Vim-Fu

search and replace

:%s/sofia/Sofia/g

High level explanation:

Using search and replace, search every line, find all occurrences of “sofia” on the line and replace with “Sofia”.

Broken down:

%  – represents all the lines in the buffer
s  – substitute
g  – global (every match on the line)

You can also find and replace across multiple buffers with:

vim file1 file2 file3

then:

bufdo %s/sofia/Sofia/g

That will find and replace “sofia” with “Sofia”  in all three files.

If you don’t have “set hidden” in your .vimrc file then you must then write your changes out, but you can use bufdo to do that too!

:bufdo! w

or, you can combine them into one command using the “|”

:bufdo s/sofia/Sofia/g | w


Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>