I. Quick Review of vi Basics * Modes and other notes Command -- Entering Commands Insert --| Replace --|-- Enter Text Append --| Visual -- Copy and Paste Blocks gvim You can type a number in front of any command to execute that command multiple times. :help :help item vimtutor :q -- quit :q! -- force quit -- quit without saving :w -- save :w file -- save file with the name file :w! -- force save :wq -- save then quit * Movement h,l,k,j - left, right, up, down -- or arrow keys on most terminals b,w - one word back or one word forward :n -- where n is the line in the file you are viewing :$ -- last line of a file * Text Editing -- Insert/Append/Join i,a -- Insert before or after the cursor I,A -- Insert at beginning or end of a line r -- replaces a single character R -- Replace multiple characters x -- delete a character dd -- delete/cut a line j -- join current line with the following * Copy/Cut/Paste yy -- copy a line y -- copy a selection dd -- delete/cut a line p -- paste v -- select some text V -- select a line at a time ^v -- select a block of text * Searches, Find and Replace /string -- search for a string Replace with regular expressions :%s/a/b/g -- Replace all 'a's with 'b's :%s/a/b/gc -- Confirm above * The all important infinite undo key -- u II. vim Goodies * Indenting, Syntax Highlighting, variable completion :set autoindent -- Simple indentation :set cindent -- Knows about C :syntax on -- Can customize colors in .vimrc * Splitting, Multiple docs -- Splitting the same doc, Splitting multiple docs :split :vsplit :split otherfile -- Ctrl ww swaps windows -- Mutltiple docs without splitting :new :next :previous -- Left out folding * Ctags and find_funcs function -- ctags -R * will ctag a source tree -- vim -t func name will take you to that item -- :tag tag will jump you to a tag -- :tn next tag -- :tp prev tag -- ^] find identifier under cursor III. Developing in Vim * Brace matching * Syntax Highlighting * Variable Completion ^p * Building -- Makefiles * Executing Programs ! * Jumping between errors :cwin -- opens a window containing all errors :cn, cp -- next,previous error :cl quick error list IV. My .vimrc -- Customization