----------------------- VIM user guide --------------------------- $ Compile-Edit Cycle: set makeprg=gcc\ file.c make vim takes you to the error line :cn for next line of error :cN for previous line of error :cwindow for the error/messages window in a separate buffer $ Auto completion ^P $ Going to Declarations ctags ^] and ^T $ Marks mark my m' and reach mark by '' mark by mj and reach by 'j (j:a-zA-Z1-0) for external files j=A-Z $ Column selection and editing goto Visual Block Editing Mode, select the column, press 'c' the column is deleted cursor goes to the leftmost part of selected area insert whatever u need to insert press Esc Wow !!! $ Encryption :X rest is intuitive, but donot forget the key $ Goto gd : goto local decl gD : goto global decl $ Jumping in C Code {,} : jumping from paragraph to paragraph separated by blank lines [[,]] : goto next/previous indented block (indented by {}) % match the next token under cursor $ That ugly ~backup,,, see help backup $ for visual block: Ctrl v $ for navigating between buffers: :n (go next) (previous not known) $ for navigating between split windows: Ctrl w w $ mouse support : set mouse=a $ match brace : Shift % $ column insert (not replace): select visual mode, I (shift i)Esc $ column replace: use c instead of I $ dw : deletes current word (words by alphanumeric sense) dW : deletes current word (words are separated only by whitespaces and can contain any non-whitespace character) $ R :enter replace mode (i.e. replace chcracters until escaped) $ ZZ : save changes and exit $ J : joins current line with next line $ D, d$ : deletes from cursor to end of line $ Using man pages: Go to the word and press 'K' or '\K'. $ Folding (in Vim6.0 or above): zf (then use ap fpr paragraph, or use visual mode to select a paragraph then press zf) $ Format paragraph by some fixed text-width: gq (to select the paragraph for formatting see above instructions) $ Select all text: gg(goes to first)v(visual)G(end) i.e. ggvG $ Remove search highlight: map :nohlsearch $ Need to ftp something and then edit ... wait :e ftp://host/p then edit ... (it asks for username/password) or have a link written somewhere. Move the cursor to any character of URL then press gf ... Voila!!! [ e.g. using vi in cu3 (solaris) is a little messy (though can be done with the commands listed below). so i am adding these lines from a Mandrake machine and using ftp to read/write the file on cu3/homepages] $ Buffers: :ls lists all buffers :ls! lists all, including hidden buffers :buf N => go to buffer N -------------------- Using the Unusable VI (not viM) ----------------------- Navigation commands: Ctrl F : Forward by one page Ctrl B : Backward by one page Ctrl D : Down by half page Ctrl U : Up by half page (Donot use the cursor keys or page up/down keys) j --- down arrow k --- up arrow h --- left arrow l --- right arrow Ret --- beginning of next line 0 --- beginning of current line (not considering whitespace) ^ --- beginning of current line (after initial whitespace) $ --- end of current line SPACE - right arrow w --- next word b --- beginning of previous word e --- end of previous word Text insertion commands: a --- append text after cursor i --- append text before cursor o --- opens new line below current line O --- opens new line above current line A --- appends text at the end of current line I --- inserts text at the beginning of current line DEL --- overwrites last charecter during text insertion (Interesting): cw --- changes characters of current word until escaped c$ --- changes text upto end of line C, cc - changes remaining current text until stopped by escaping