Vim cheatsheet

Reference commands for the vim text editor.


Vim currently supports 7 basic modes.

  1. Normal mode.
  2. Visual mode (v / V).
  3. Select mode.
  4. Insert mode (i).
  5. Command-line mode (:). Serves as a prefix for many commands.
  6. Ex mode.
  7. Terminal-job mode.

Esc returns the editor to normal mode. This will also cancel a partial, unwanted command.

Refer to :help vim-modes for details, including information on the additional advanced editor modes, which aren’t covered here.

Saving and exiting

Closing out of vim is often a frustrating step for new users.

Text editing basics

Note that vim uses different naming conventions.

Normal Vim
cut delete
copy yank
paste put


These commands will enter insert mode.

Use Esc to exit back to normal mode.



Delete (cut)

Almost all deletion commands are performed by typing d followed by a motion.

Yank (copy)

Put (paste)


Also refer to visual mode, which is extremely useful for text selection.

Navigation (cursor movement)


Vim uses the home row for navigation. The arrow keys also work, but these are faster to type because you don’t have to lift your hand.

Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.




Scrolling (screen)

See :help scroll for details.

Fast move in a buffer

Visual mode (v).

Selecting a visual mode type

Marking text

Commands that work on marked text

Search and replace

Replace (substitution)

Substitution is accomplished with the :s command. It is commonly used in combination with ranges or the :g command. Vim uses a syntax similar to sed:


Flags (optional)




File and window management

Window (buffer) management

Vim supports multiple files, tabs, and window splitting. I recommend using this instead of tmux whenever possible because it’s easier to manage the clipboard.

Multiple files

Vim supports opening multiple files directly from the shell.

vim -o file1 file2

This will open two files and split them vertically.

Alternatively, you can manage files inside vim.




Toggle line numbers


Vim supports customization through a .vimrc configuration file, and plugins in a .vim directory.

Note that version 8 now has a native third-party package manager.