Vim Cheatsheet


First, my own personal .vimrc can be found at dotfiles.


Vim supports multiple "windows" for manipulating multiple buffers/files.

  •  :sp (splits the window)
  •  :sp filename (splits the window and opens the specified file)
  •  :Nsp (where N is an integer, splits the window, the new window at the top being N lines tall)
  •  :vsp (like :sp, but splits vertically)
  • <C-w><C-w> (alternate open windows)
  • <C-w>+ (enlarge a horizontal window)
  • <C-w>- (shrink a horizontal window)
  • <C-w>> (increase right-width of a vertical window)
  • <C-w>< (decrease right-width of a vertical window)
  • <C-w>= (all windows equal size)
  •  :buffers (list buffers i.e. open files)
  •  :sb N (where N is an integer or file name, split the window and begin editing the specified buffer in the new window)
  •  :bd N (where N is an integer, deletes/closes the buffer at that index)
  •  :ball (open a new window for each buffer)
  •  :hide (close this window)
  •  :only (close all other windows)

Patching & File Comparison

Initiate diff mode using: vimdiff file1file2 [file3, file4...]
  • :do - get the other window's version of a given section (requires exactly 2 windows/files)
  • :dp - push the current section into the other windows

Code Completion

  • <C-x><C-o> - open code-completion on a partially typed keyword/function name


Sam Briesemeister,
Jul 27, 2009, 5:17 PM