Vim keyboard shortcuts
Vim is the modal text editor found on virtually every Unix system, built around composable commands instead of chorded shortcuts. Its keys are identical on every platform, which is why Vim muscle memory follows you to any server or editor with a Vim mode. These are the core default commands in Normal mode unless noted. This cheat sheet covers 88 default shortcuts for Windows and Mac.
Modes
| Insert before cursor | ii |
| Insert at start of line | II |
| Append after cursor | aa |
| Append at end of line | AA |
| Open new line below | oo |
| Open new line above | OO |
| Visual mode (character) | vv |
| Visual line mode | VV |
| Visual block mode | Ctrl+VCtrl+V |
| Replace mode | RR |
| Return to Normal mode | EscEsc |
| Command-line mode | :: |
Basic Movement
| Move left / down / up / right | h / j / k / lh / j / k / l |
| Next word start | ww |
| Previous word start | bb |
| End of word | ee |
| Start of line | 00 |
| First non-blank character of line | ^^ |
| End of line | $$ |
| First line of file | gggg |
| Last line of file | GG |
| Go to line N | NGNG |
| Next paragraph / block | }} |
| Previous paragraph / block | {{ |
| Jump to matching bracket | %% |
Scrolling & Screen
| Scroll half page down | Ctrl+DCtrl+D |
| Scroll half page up | Ctrl+UCtrl+U |
| Scroll full page down | Ctrl+FCtrl+F |
| Scroll full page up | Ctrl+BCtrl+B |
| Top of screen | HH |
| Middle of screen | MM |
| Bottom of screen | LL |
| Center current line on screen | zzzz |
In-Line Search
| Find character forward in line | f{char}f{char} |
| Find character backward in line | F{char}F{char} |
| Move till before character | t{char}t{char} |
| Repeat last f/t motion | ;; |
| Repeat last f/t motion backward | ,, |
Editing
| Delete character under cursor | xx |
| Delete line | dddd |
| Delete word | dwdw |
| Delete to end of line | DD |
| Change word (delete and insert) | cwcw |
| Change entire line | cccc |
| Change to end of line | CC |
| Replace single character | r{char}r{char} |
| Substitute character (delete and insert) | ss |
| Join line below to current | JJ |
| Toggle case of character | ~~ |
| Undo | uu |
| Redo | Ctrl+RCtrl+R |
| Repeat last change | .. |
| Indent line | >>>> |
| Outdent line | <<<< |
| Auto-indent line | ==== |
Copy & Paste (Yank)
| Yank (copy) line | yyyy |
| Yank word | ywyw |
| Paste after cursor | pp |
| Paste before cursor | PP |
| Yank selection (Visual mode) | yy |
| Delete (cut) selection (Visual mode) | dd |
Search & Replace
| Search forward | /pattern/pattern |
| Search backward | ?pattern?pattern |
| Next search match | nn |
| Previous search match | NN |
| Search word under cursor forward | ** |
| Search word under cursor backward | ## |
| Replace all in file | :%s/old/new/g:%s/old/new/g |
| Replace all with confirmation | :%s/old/new/gc:%s/old/new/gc |
Files & Saving
| Save file | :w:w |
| Quit | :q:q |
| Save and quit | :wq:wq |
| Quit without saving | :q!:q! |
| Save and quit (Normal mode) | ZZZZ |
| Edit / open file | :e filename:e filename |
Windows & Tabs
| Split window horizontally | Ctrl+W SCtrl+W S |
| Split window vertically | Ctrl+W VCtrl+W V |
| Switch between windows | Ctrl+W WCtrl+W W |
| Close current window | Ctrl+W QCtrl+W Q |
| Open new tab | :tabnew:tabnew |
| Next tab | gtgt |
| Previous tab | gTgT |
Marks & Macros
| Set mark a at cursor | mama |
| Jump to line of mark a | 'a'a |
| Record macro into register a | qaqa |
| Stop recording macro | |
| Play macro in register a | @a@a |
| Repeat last played macro | @@@@ |
Put your top Vim shortcuts on real keys
The five Vim actions most worth binding to a physical macropad key:
EscEsc Return to Normal mode The most pressed key in Vim; a big dedicated Esc saves the pinky stretch.
:w:w Save file The save reflex fires constantly; one key for the whole :w Enter sequence.
:wq:wq Save and quit The canonical Vim exit as a single physical key ends every session cleanly.
.. Repeat last change The dot command is Vim's superpower for repetitive edits.
@a@a Play macro in register a Replaying a recorded macro on demand automates any repetitive edit.
I hand-build small-batch programmable macropads (QMK/VIA) in Barcelona. One press, any shortcut, any app.
Vim shortcut FAQs
How do I exit Vim?
Press Esc to make sure you are in Normal mode, then type :q and Enter to quit, :wq to save and quit, or :q! to quit and discard changes. ZZ in Normal mode also saves and quits.
Are Vim shortcuts the same on Windows and Mac?
Yes. Vim commands are plain keystrokes interpreted by the editor itself, not OS-level shortcuts, so hjkl, dd, :wq and everything else work identically on Windows, Mac, and Linux.
What do the letters hjkl do in Vim?
In Normal mode they move the cursor: h left, j down, k up, l right. They sit on the home row so you can navigate without reaching for the arrow keys.
How do I copy and paste in Vim?
Yank with y (yy copies a line), then paste with p after the cursor or P before it. Deleted text (dd, dw, x) also goes into the register and can be pasted with p.
How do I search and replace in Vim?
Type :%s/old/new/g and press Enter to replace every match in the file. Add c at the end (:%s/old/new/gc) to confirm each replacement, or use /pattern and n to just search.