More useful vim tips

Go to place in file

:G    End of file

1G  Start of file

<n>G    (or) :n Go the nth line of file

Find and Replace

This is of the form %s/<text to find>/<text to replace>/<options>

%s/foo/bar/g : Replaces all occurrences of  foo with bar

%s/\<foo\>/bar/g : Replaces all EXACT matches of the word foo  with bar

%s/foo/bar/gc : The c option, asks for a confirmation before replacing

Advertisements

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