CCoommmmoonnllyy UUsseedd vvii CCoommmmaannddss OOppeerraattoorrss OOppeerraannddss d delete hjkl cursor movement keys (left, down, up, right) p paste after/below cursor wbe next word, back word, end word y yank WBE same as above, but ignore punctuation i insert before cursor / search for string (use ? for reverse search) a append after cursor % find matching (, {, or [ r replace ( ) previous sentence, next sentence s substitute { } previous paragraph, next paragraph c change [[ ]] previous section, next section ! shell command see sseett ppaarraaggrraapphhss//sseeccttiioonnss _nG move to line _n CCoommmmoonn MMaaccrrooss /0 ^ $ move to: column /0, first non‐space, or EEOOLL I insert at BBOOLL (same as ^i) fx cursor forward to char x A append at EEOOLL (same as $a) tx cursor forward to char x minus 1 D delete to EEOOLL (same as d$) ; last f or t again C change to EEOOLL (same as c$) , last f or t in reverse direction R replace (overstrike) mode ´x (apostrophe x) move to line containing mark x o open line below cursor `x (backtic x) move exactly to mark x O open line above cursor ´´ (2 apostrophes) move to line of last jump point x delete one char (same as dl) `` (2 backtics) move exactly to last jump point ZZ save and exit (same as :wq) :w! write file ("!"=forced; used to override lack of write permis‐ sion, etc) :q! quit without save ("!"=forced) BBuuffffeerrss MMiisscceellllaanneeoouuss "x x is /0‐9: delete buffers u undo last change "x x is a‐z: user buffers U undo all changes to current line "X X is A‐Z: append to buffer . perform last change again mx set mark x; x is letter A through Z (not case‐ sensitive) Numeric arguments may prefix any and all commands, although some don’t make sense, such as % or $. Interesting examples of numeric prefixes are 36i‐*^[ and 2/0r_ ‐2‐ EExx ((ccoolloonn‐‐mmooddee)) ccoommmmaannddss:: In the following commands, _f_i_l_e may be either a filename, or a shell command if prefixed with !. Filenames are _g_l_o_b_b_e_d by the shell before vi uses them (shell wildcards are processed before the filenames are used). Address ranges may be used immediately after the colon in the commands below. All line number ranges are inclusive of the lines at either end of the range. Address range examples: :1,$ From line 1 to EEOOFF. :1/0,2/0 From line 1/0 to line 2/0. :.,.+1/0 From current line to current line + 1/0 (11 lines total). :’a,’d From mark a to mark d. :/start/,/end/ From the line containing start to the line con‐ taining end. Commands which change the file being edited: :e _f_i_l_e Edit alternate file; while editing alternate, use :e # to return to previous file. _f_i_l_e may be # for previous file or % for current file. Also useful for modifying filename, as in :e %.txt :n _f_i_l_e_s Edits next file as specified on command line; _f_i_l_e_s will replace command line filenames with the given names, if specified. Shell wildcards are very useful here. Also command substitution, ie. :n $(grep ‐l regex *.c) :args Lists the files from the command line (may be modified by :n, above). :rew Restarts editing at first file (rewinds the argument list). Commands which modify the text buffer or disk file being edited: :g/RE/_c_m_d Globally search for regular expression and execute _c_m_d. The RE may be any sed‐compatible extended regular expression. The command can be any colon‐ mode command. Common commands are s, d, and p. :s/RE/str/_o_p_t Substitute str for RE; use _o_p_t as option list. Valid options are c (confirm), g (globally in line), p (print after change). These commands are useful when _f_i_l_e is replaced with shell command(s) such as :w !sort or :r !date – remember that address ranges can prefix these commands as well: :w _f_i_l_e Write contents of current buffer to _f_i_l_e :r _f_i_l_e Read contents of _f_i_l_e into buffer after cursor These commands control the environment in which vi operates: :set _o_p_t Set or query options; _o_p_t is option. Also try :set all :abbr ab phrase Abbreviation ab of string phrase; remove with :unab ab :map key str Command (:map) or input (:map!) macro for key of str; remove with :unmap key. Here is an example of what the _._e_x_r_c startup file looks like in my $$HHOOMMEE directory: set report=1 shiftwidth=4 wrapmargin=1/0 set autoindent beautify exrc magic nomesg set modelines opt showmode nowrapscan map #3 :q!^^VV^^MM map! #3 ^^VV^^[[:q!^^VV^^MM ‐3‐ Some other command settings are ignorecase (ic), autowrite (aw), and showmatch (sm).