Vim Cheat Sheet: The Complete Shortcuts & Commands Reference
Vim is a free, open-source modal text editor where every keyboard shortcut depends on the active mode Normal, Insert, Visual, or Command-line. This cheat sheet covers 100+ Vim shortcuts for cursor movement, editing, copy and paste, search and replace, macros, and more, organized by task so you can find any command fast. Every shortcut is verified for the latest Vim and works in Neovim too.
Whether you’re learning Vim for the first time or just need a quick reference, bookmark this page or download the free PDF to keep it handy. If you’re new to Vim, start with these 15 shortcuts. Master these first and you’ll be able to open, edit, save, and exit files comfortably before moving on to the full command set.
Top 15 Vim Shortcuts for Beginners
| # | Shortcut | What it does |
|---|---|---|
| 1 | i | Enter Insert mode (start typing) |
| 2 | Esc | Return to Normal mode |
| 3 | :w | Save the file |
| 4 | :q | Quit |
| 5 | :wq | Save and quit |
| 6 | :q! | Quit without saving |
| 7 | h j k l | Move left, down, up, right |
| 8 | x | Delete a character |
| 9 | dd | Delete (cut) a line |
| 10 | yy | Copy a line |
| 11 | p | Paste |
| 12 | u | Undo |
| 13 | Ctrl + r | Redo |
| 14 | /pattern | Search for text |
| 15 | :%s/old/new/g | Find and replace |
Cursor Movement Shortcuts
| Action | Shortcut |
|---|---|
| Move left | h |
| Move down | j |
| Move up | k |
| Move right | l |
| Jump to start of next word | w |
| Jump to start of next word (incl. punctuation) | W |
| Jump to end of word | e |
| Jump to end of word (incl. punctuation) | E |
| Jump back to start of word | b |
| Jump back to start of word (incl. punctuation) | B |
| Start of line | 0 |
| First non-blank character of line | ^ |
| End of line | $ |
| Last non-blank character of line | g_ |
| Jump to matching bracket () {} [] | % |
| Go to first line of file | gg |
| Go to last line of file | G |
| Go to line number 5 | 5G |
| Jump to next occurrence of character x | fx |
| Jump to before next occurrence of x | tx |
| Next paragraph / code block | } |
| Previous paragraph / code block | { |
| Center cursor on screen | zz |
| Move screen down half a page | Ctrl + d |
| Move screen up half a page | Ctrl + u |
| Move screen down one full page | Ctrl + f |
| Move screen up one full page | Ctrl + b |
Insert Mode Shortcuts
| Action | Shortcut |
|---|---|
| Insert before the cursor | i |
| Insert at the beginning of the line | I |
| Append after the cursor | a |
| Append at the end of the line | A |
| Open a new line below | o |
| Open a new line above | O |
| Append at the end of the word | ea |
| Delete word before cursor (insert mode) | Ctrl + w |
| Insert contents of register x | Ctrl + r x |
| Exit insert mode | Esc or Ctrl + c |
Editing Shortcuts
| Action | Shortcut |
|---|---|
| Replace a single character | r |
| Replace many characters until Esc | R |
| Join line below to current (one space) | J |
| Join line below without space | gJ |
| Change entire line | cc |
| Change to end of line | c$ or C |
| Change entire word | ciw |
| Change to end of word | cw |
| Delete character and substitute text | s |
| Delete line and substitute text | S |
| Switch case up to motion | g~ |
| Make text uppercase up to motion | gU |
| Make text lowercase up to motion | gu |
| Transpose two letters | xp |
| Undo | u |
| Redo | Ctrl + r |
| Repeat the last command | . |
Cut & Paste Shortcuts
| Action | Shortcut |
|---|---|
| Yank (copy) a line | yy |
| Yank 2 lines | 2yy |
| Yank a word | yw |
| Yank word under the cursor | yiw |
| Yank to end of line | y$ or Y |
| Paste after the cursor | p |
| Paste before the cursor | P |
| Delete (cut) a line | dd |
| Delete (cut) 2 lines | 2dd |
| Delete (cut) a word | dw |
| Delete (cut) to end of line | d$ or D |
| Delete (cut) a single character | x |
| Delete lines 3 to 5 | :3,5d |
Visual Mode Shortcuts
| Action | Shortcut |
|---|---|
| Start visual mode (character-wise) | v |
| Start linewise visual mode | V |
| Start visual block mode | Ctrl + v |
| Move to other end of marked area | o |
| Move to other corner of block | O |
| Mark a word | aw |
| A () block | ab |
| A {} block | aB |
| A <> tag block | at |
| Inner () block | ib |
| Inner {} block | iB |
| Exit visual mode | Esc |
Visual Commands Shortcuts
| Action | Shortcut |
|---|---|
| Shift text right | > |
| Shift text left | < |
| Yank (copy) marked text | y |
| Delete marked text | d |
| Switch case | ~ |
| Make marked text lowercase | u |
| Make marked text uppercase | U |
Search & Replace Shortcuts
| Action | Shortcut |
|---|---|
| Search forward for pattern | /pattern |
| Search backward for pattern | ?pattern |
| Repeat search, same direction | n |
| Repeat search, opposite direction | N |
| Replace all old with new in file | :%s/old/new/g |
| Replace all, with confirmation | :%s/old/new/gc |
| Remove search highlighting | :noh |
| Search pattern across multiple files | :vimgrep /pattern/ **/* |
Registers & Marks Shortcuts
| Action | Shortcut |
|---|---|
| Show register contents | :reg |
| Yank into register x | “xy |
| Paste contents of register x | “xp |
| Yank into system clipboard | “+y |
| Paste from system clipboard | “+p |
| List all marks | :marks |
| Set mark a at current position | ma |
| Jump to mark a | `a |
| Jump to position before last jump | “ |
| Jump to position of last change | `. |
Macros in Vim
| Action | Shortcut |
|---|---|
| Start recording macro into register a | qa |
| Stop recording | q |
| Play macro a | @a |
| Replay last-run macro | @@ |
| Run macro a 5 times | 5@a |
How to record a macro (step-by-step): Press qa to start recording into register a → perform your sequence of edits → press q to stop → press @a to replay it, or 5@a to repeat it five times. Macros are how Vim users automate repetitive edits across many lines.
Working with Files, Windows & Buffers Shortcuts
| Action | Shortcut |
|---|---|
| Edit a file in a new buffer | :e filename |
| Go to next buffer | :bnext |
| Go to previous buffer | :bprev |
| Delete (close) a buffer | :bd |
| List all open buffers | :ls |
| Split window horizontally | Ctrl + ws |
| Split window vertically | Ctrl + wv |
| Switch between windows | Ctrl + ww |
| Quit a window | Ctrl + wq |
| Make all windows equal size | Ctrl + w= |
| Open a file in a new tab | :tabnew |
| Move to next tab | gt |
| Move to previous tab | gT |
| Close current tab | :tabclose |
Folding Shortcuts
| Action | Shortcut |
|---|---|
| Toggle fold under cursor | za |
| Open fold under cursor | zo |
| Close fold under cursor | zc |
| Open all folds one level | zr |
| Close all folds one level | zm |
Exit Shortcuts
| Action | Shortcut |
|---|---|
| Write (save), don’t exit | :w |
| Write (save) and quit | :wq or 😡 or ZZ |
| Quit (fails if unsaved changes) | :q |
| Quit, discard all changes | :q! or ZQ |
| Save and quit all tabs | :wqa |
Vim Modes Explained
Vim is a modal editor, which means the same key does different things depending on which mode you’re in. This is the concept that confuses every beginner pressing j moves your cursor down in one mode but types the letter “j” in another. Once modes click, the rest of Vim follows naturally.
Vim has four modes you’ll use daily:
Normal Mode
This is where Vim starts, and where you’ll spend most of your time. In Normal mode, keys are commands, not text dd deletes a line, yy copies one, j and k move the cursor. Think of Normal mode as the “navigation and editing” home base. Press Esc to return to Normal mode from anywhere.
Insert Mode
This is the mode that behaves like a regular text editor what you type appears on screen. You enter Insert mode with commands like i (insert before cursor), a (append after cursor), or o (open a new line below). Press Esc to leave Insert mode and return to Normal mode.
Visual Mode
Visual mode is for selecting text before acting on it. Press v for character-wise selection, V for line-wise, or Ctrl + v for block selection. Once text is highlighted, an operator like d (delete) or y (yank/copy) acts on the whole selection.
Command-Line Mode
Entered by typing : from Normal mode, this is where you run commands like :w (save), :q (quit), and :%s/old/new/g (search and replace). It’s also how you access search with / and ?.
Here’s how the modes connect:
| From → To | Key |
|---|---|
| Any mode → Normal | Esc |
| Normal → Insert | i, a, o, I, A, O |
| Normal → Visual | v, V, Ctrl + v |
| Normal → Command-line | : |
| Normal → Search | /, ? |
Key insight: When you’re lost in Vim, press Esc twice. This guarantees you’re in Normal mode, the safe starting point for any command.
How Vim Commands Work: Operator + Motion
The reason Vim feels powerful once it clicks is that its commands work like a language. Instead of memorizing hundreds of separate shortcuts, you learn a small set of building blocks and combine them. Most Vim commands follow this pattern:
[count] + operator + motion
An operator is the action delete, change, yank (copy). A motion is what the action applies to a word, a line, to the end of the line. You combine them like a verb and an object.
Take the delete operator d:
| Command | Operator | Motion | Result |
|---|---|---|---|
| dw | d (delete) | w (word) | Delete to the start of the next word |
| d$ | d (delete) | $ (end of line) | Delete to the end of the line |
| dd | d (delete) | d (whole line) | Delete the entire line |
| 2dw | d (delete) | w × 2 | Delete two words |
The same logic applies to other operators. Swap d for c (change) and you get cw (change a word) or c$ (change to end of line). Swap it for y (yank) and you get yw (copy a word) or y$ (copy to end of line).
This is why you don’t need to memorize every shortcut in this cheat sheet separately. Learn the operators (d, c, y), learn the motions (w, b, e, $, 0, G), and you can mix them into hundreds of precise edits.
Think of it as a sentence: d (delete) + w (word) = dw, “delete word.” Once you read commands this way, Vim stops being a list of keys and becomes a grammar you compose.
The [count] prefix multiplies any command. 3j moves down three lines, 2dd deletes two lines, 5yy copies five. Put a number before almost any command and Vim repeats it that many times.
Vim Shortcuts FAQ
How do I exit Vim?
To exit Vim, first press Esc to make sure you’re in Normal mode, then type :q and press Enter to quit. If you’ve made changes you want to keep, use :wq to save and quit. To quit without saving, use :q!.
How do I save and quit in Vim?
Press Esc, then type :wq and press Enter. This writes (saves) the file and quits in one step. You can also use :x, which saves and quits but only writes the file if there were changes.
How do I copy and paste in Vim?
In Normal mode, position your cursor and press yy to copy (yank) a line, then move to the destination and press p to paste after the cursor or P to paste before it. To copy a single word, use yw.
How do I undo and redo in Vim?
Press u in Normal mode to undo the last change. To redo, press Ctrl + r. You can undo multiple times by pressing u repeatedly.
Are Vim shortcuts the same on Mac?
Yes, the core Vim shortcuts are identical on macOS, Linux, and Windows because they’re built into Vim itself, not the operating system. The main difference is that some Mac keyboards require remapping if you want to hold a navigation key (like j) to repeat it.
Are Vim and Neovim shortcuts the same?
Almost entirely, yes. Neovim is a fork of Vim and keeps full compatibility with Vim’s default keybindings, so every shortcut in this cheat sheet works in both. Neovim adds extra features and plugin options, but the core commands are unchanged.
Is Vim hard to learn?
Vim has a steep initial learning curve because it’s a modal editor keys behave differently depending on the mode. But once you understand modes and the operator-plus-motion grammar, the commands become intuitive. Most users feel comfortable with the basics within a week of regular use. Running vimtutor in your terminal is the fastest way to start.
How do I install Vim?
Vim comes pre-installed on most Linux and macOS systems. To install or update it, use your package manager: sudo apt install vim on Debian/Ubuntu, brew install vim on macOS, or download the installer from vim.org on Windows.
Conclusion
Vim rewards the time you invest in it. The learning curve is real but once modes and the operator-plus-motion grammar click, you stop reaching for the mouse entirely and edit at the speed of thought. You don’t need to memorize all 100+ shortcuts on this page. Start with the 15 beginner shortcuts above, keep this cheat sheet open in a tab, and add a few new commands each week. Within a month, the muscle memory takes over.
Every shortcut here works in both Vim and Neovim, and on Linux, macOS, and Windows alike. The fastest way to build fluency is to run vimtutor in your terminal it’s a free, interactive lesson built into Vim itself and then practice on real files.
READ NEXT:





