Vim Cheat Sheet

Motions, operators, text objects, registers, macros and window commands for Vim and Neovim.

Vim reference
Runs locally in your browser

About the Vim Cheat Sheet

Vim is built from a small grammar rather than a long list of shortcuts: an operator, an optional count, then a motion or a text object. Learn d, c and y alongside w, ap and i" and you can express thousands of edits without memorising any of them one by one. The tables below are grouped that way, so the motions and the text objects sit right next to the operators that consume them.

Thirteen sections cover the modes, cursor movement, every route into insert mode, editing operators, text objects, registers and the system clipboard, undo and macros, search and replace including the :g and :v line filters, visual mode with its block edits, buffers, window splits, marks and folds, and the settings worth remembering. Commands normally learned the hard way appear too, such as :w !sudo tee % for a file you opened without write access, and :sort u for sorting a buffer while dropping duplicates.

All of it applies to Vim 8, Neovim and the vi keybindings built into most editors, because none of these commands depends on a plugin. Filter for a word such as buffer, macro or fold to shorten the list while you are still learning, then copy the Markdown to keep beside your terminal. For text surgery that is easier outside the editor, try the Find and Replace tool or the Diff Checker.

How to use

  1. Start with the Cursor motion and Editing operators sections if you are new, since those two combine into most commands.
  2. Use the filter box to find a key you only half remember, for example register, indent or fold.
  3. Copy or download the sheet as Markdown so it stays available without a browser.

Common questions

How do I quit Vim?
Press Escape, then type :q and Enter. Use :wq to save first, or :q! to leave without keeping your changes.
What is the difference between i and a in Vim?
i starts inserting before the character under the cursor and a starts after it. The uppercase forms I and A jump to the first non blank character and to the end of the line.
How do I copy from Vim to the system clipboard?
Use the plus register: "+y copies and "+p pastes. Your build needs clipboard support, which :version will confirm with a plus sign next to clipboard.
How do I replace text across a whole file?
Run :%s/old/new/g. Add c to confirm each replacement and i to make the match case insensitive.
What does the dot command do?
It repeats your most recent change wherever the cursor now sits, which makes small repeated edits much faster than recording a macro.