Very essential Vim cheat sheet

Apart from the basics, which you should know to use vim, there are many useful commands that I always forget, and every time I need to search on Internet.
Here's my very little cheat sheet.

Enabling/Disabilng row numbers:

:set number 
:set nonumber

Enabling/Disabling Syntax Highlighter:

:syntax on
:syntax off

Text search tips (where "text" is the text to search)

search forward: 
/text 

search backward: 
?text 

search case insensitive:
/\\ctext 

Search and replace (OLD to NEW):

First occurrence on current line:
:s/OLD/NEW
  
Globally (all) on current line:
:s/OLD/NEW/g 

Between two line 123 and 345:                 
:123,345s/OLD/NEW/g
  
Every occurrence in file:
:%s/OLD/NEW/g 

Move to the top and to the end of the file:

move to the top of the file:
:0 

move to line 123 of the file:
:123

move to the end of the file:
:$ 

Maybe some new tricks will be added. (Post your suggestions in comments!)


One Response to “Very essential Vim cheat sheet”  

  1. 1 Russell

    How about:

    move to a specific line number:
    G (e.g. 35G jumps to line 35)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



Calendar

August 2009
M T W T F S S
« Jul   Sep »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:

Archives


Categories

Tag Cloud


Listening