= [%;.;$;*;,] where %=all lines, .=current line, $=last line *=visual highlighted special characters: \r carriage return, \n end-of-line, \s space, \t tab (during edit modes) Ctrl-[v;q][Esc;Ctrl-;] = [^[; ^; ] Ctrl-k = to limit characters per line : ":set tw=79" to insert line numbers : ":g/^/exe "s/^/".line(".")" to replace tabs with spaces : ":retab" to remove trailing spaces : ":%s/\s\+$/" to remove trailing ^M : ":set ff=unix" and write to change highlighting : ":set ft=" where is programming: [asm;basic;c;cpp;cs;d;java;vb] program_alt: [python;ruby;verilog;vhdl] misc: [conf;dosini;make;registry;spice;tex;vim] script: [awk;dosbatch;maple;matlab;perl] shell: [csh;sh;tcsh;zsh] web: [aspvbs;html;php;xhtml;xml] Basic commands ============== [Shift-]i Insert [places cursor at start-of-line] [Shift-]o Insert line after current line [before current line] [Shift-]a Append [places cursor at end-of-line] Shift-r Replace (same as toggling Insert) [Shift-]s Substitude character [cut whole line]; same as 'r' remain in normal mode Shift-c Cut from cursor to last character of line x Delete character u Undo Ctrl-r Redo :browse Opens directory browser window :e! Open for editing (! reload file) :[v]split Split window to edit [vertical split]; default current file 'Ctrl-w[v;s]' :[v]new Split window to new file [vertical split] :w! Write to (! override read-only); default current file :q! Quit (! without saving, same as 'ZQ') :x Same as write and quit ':wq' or 'ZZ' d[d;w;$] Cut [lines; words; until end-of-line] y[y;w;$] Copy [lines; words; until end-of-line] [Shift-]p Paste below current line or on right of cursor [above current line or on left of cursor] [/;?][\c;\<;\>] Search [forward; backward] for ; [case-insensitive; start-of-word; end-of-word] '[Shift-]n' to continue next/prev [g]Shift-[3;Rclick][8;Lclick] [Partial] Search for word under cursor [search in reverse order] :[d;y] Select lines to [cut; copy] :s///g Search & replace (global line) :s Repeat last substitution on current line :g!// Search & perform command (! not match; same as :v) = [d;y] :s Repeat last substitution on current line g[~;U;u]iw Word [toggle; upper; lower] case Navigation & selection ====================== 0 Go to start-of-line Shift-6 Go to first non-blank character of line Shift-4 Go to end-of-line g_ Go to last non-blank character of line Shift-g Go to line ; 'H' for top, 'M' for middle, 'L' for last line of screen gg Go to first line, first non-blank character Shift-g Go to last line, first non-blank character [w,b] Scroll beginning word-by-word (same as Shift-right arrow) [forward; backward] [e,ge] Scroll end word-by-word [forward; backward] [(;)] Scroll beginning sentence-by-sentence [backward; forward] [{;}] Scroll end paragraph-by-paragraph [backward; forward] Ctrl-e Scroll down one-line Ctrl-y Scroll up one-line Ctrl-d Scroll down half-page Ctrl-u Scroll up half-page Ctrl-f Scroll down full-page (same as Shift-down arrow) Ctrl-b Scroll up full-page (same as Shift-up arrow) v Visual highlighting => 'd' deletes highlighted characters => 'Shift-d' cuts lines Ctrl-v Visual block highlighting => 'Shift-i' inserts highlighted => 'Shift-a' appends highlighted => 'Shift-d' cuts until end-of-lines => ':d' cuts lines (works for visual too) => 'gq' or 'gw' justifies textwidth => 'r' replaces all characters m Mark cursor position [`;'] Go to marked cursor [position; start-of-line] Ctrl-[o;i] Go to [last; next] cursor position Ctrl-w[w;arrow] Switch window focus [default order; according to direction] Ctrl-w[r;x] [Rotate; exchange window] Ctrl-w[=;+-;<>;Ctrl-_;|] Resize windows [all same; height; width; max height; max width] Special functions ================= . Repeat last keystrokes Ctrl-a Repeat last keystrokes (during edit modes) q Start recording keystrokes; 'q' stops recording Shift-2 Playback recorded keystrokes gqq Justify textwidth Ctrl-[a;x] [Increment; decrement] number under cursor Ctrl-w Word deletion (during insert mode) Ctrl-[n;p] Word completion [next; previous] (during edit modes) Ctrl-x,Ctrl-l,Ctrl-[n;p] Line completion (during edit modes) Ctrl-x,Ctrl-t,Ctrl-[n;p] Thesaurus completion (during edit modes) [0;^]Ctrl-[t;d] Indent [forward; backward] (during edit modes); delete all indent [restore indent on next line] Ctrl-[y;e] Duplicate character [above; below] cursor (during edit modes) [=]Shift-5 Detect bracket ends [C-indent autofix code block] ga Display ASCII value of character under cursor g,Ctrl-g Display cursor position, word & byte count [g]J Joins current line with next line [do not insert/remove spaces] z[Shift-]a Open/close fold under cursor [recursively] !! Execute shell command Shift-k Man page on cursor word :r Insert contents :help Vim Help; 'Ctrl-d' to view all possibilities [Shift-]f Finds next [prev] on current line; useful for delimiter characters (periods, colons, etc.)