Vim Cheatsheet

woman on her laptop in front of a yellow blob

Looking for a Vi/Vim commands cheat sheet with all the basic and easy shortcuts for your vim editor - we have got you covered!

Standard

  • h j k l : Arrow keys
  • w : Go to the next word
  • b : Go to the previous word
  • e : Go to the next word at the end of the word
  • ge : Go to the previous word at the end of the word
  • 0 : Go to the start of the line
  • $ : Go to the end of the line
  • n : Go to the next matching search pattern
  • N : Go to the previous match
  • * : Next whole word that is under the cursor
  • # : The previous word that is under the cursor

Searching for Characters

  • f [char] : Move forwards to the character supplied within the braces
  • F [char] : Move backward to the character supplied within the braces
  • t [char] : Move forward to just before the character
  • T [char] : Move backward to just before the given character

Editing Text

  • i : Start insert mode to append at the cursor
  • a : Append after cursor
  • A : Append from the end of the line
  • I: Append from the beginning of the line
  • o : Add a blank line below the current line / next line
  • O : Add a blank line above the current line / previous line
  • Esc or Ctrl+[ : Exit insert mode
  • d : Delete
  • dd : Delete line
  • s : Delete character and insert
  • S : Delete line and insert
  • c : Delete, then open insert mode
  • cc : Delete line, then open insert mode
  • r : Replace one character
  • R : Open replace mode
  • u : Undo changes
  • [number]Ctrl+r : To redo multiple undos with a single command, you can use this syntax. Here [number] should be replaced by the actual number of redoes you want to perform, then press and hold Ctrland type r.
  • dd : Delete or cut a line
  • x : Delete or cut the current character
  • X - Delete or cut the previous character

Related: How to select all in Vim

How To ‘Select All’ in Vim
In this guide, we cover the main methods with which you can select all in the vim/vi editor.

Copying and Pasting to Clipboard

  • yy : Yank or copy a line
  • p : Paste after the cursor position
  • P : Paste before the cursor position
  • d / c : Copy the deleted text

Saving and Exiting

  • :w : Save the file without quitting
  • :wq : Save and quit
  • :q : Quit (this command fails if anything in the document has changed without saving)
  • :q! : Quit and throw away changes all unsaved changes
  • :qa : Close all files
  • :qa! : Close all files without saving

Shortcuts and Commands for Working with Multiple Files

  • Ctrl + ws : split window
  • Ctrl + wv : split window vertically
  • Ctrl + ww : switch windows
  • Ctrl + wq : quit a window
  • Ctrl + wx : exchange current window with next one
  • Ctrl + w=  : make all windows equal height & width
  • Ctrl + wJ : make current window full width and positions it at the bottom
  • Ctrl + wK : Makes the current window full width and positions it at top
  • Ctrl + wh : In a vertical split, move cursor to the window on the left
  • Ctrl + wl : In a vertical split, move cursor to the window on the right
  • Ctrl + wj : In a horizontal split, move cursor to the window below
  • Ctrl + wk : In a horizontal split, move cursor to the window above
  • Ctrl + wH : Makes the current window full height and positions it at the far left
  • Ctrl + wL : Makes the current window full height and positions it at the far right