Skip to content
Tags

,

:%s in vim

November 21, 2011

:127, 215 s/foo/bar means

change the first occurrence of ‘foo’ to ‘bar’ on each line between 127 and 215

 

:%s  is synonymous with :1,$. which means change all lines.

 

the g from gc stands for global – applying a subsequent command to all lines which match a pattern

 

the opposite of that is v. v applies the command for all lines that do not match the pattern. just like grep -v

 

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: