Vim keyboard shortcuts
Vim is a language of motions, operators, and modes rather than a list of isolated hotkeys. This reference covers the normal, insert, visual, search, window, and command-line paths that make the official quick reference useful at the keyboard.
Windows, macOS, Linux · 69 shortcutsModes and movement
Start in normal mode, move by character or text object, and use the same motions as building blocks for operators.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Insert before the cursor | i | i | i |
| Insert after the cursor | a | a | a |
| Insert at the first non-blank character | I | I | I |
| Append at the end of the line | A | A | A |
| Open a new line below | o | o | o |
| Open a new line above | O | O | O |
| Return to normal mode | Esc | Esc | Esc |
| Move left | h | h | h |
| Move down | j | j | j |
| Move up | k | k | k |
| Move right | l | l | l |
| Move to the first non-blank character0 moves to column one. | ^ | ^ | ^ |
| Move to the end of the line | $ | $ | $ |
| Move to the next word start | w | w | w |
| Move to the previous word start | b | b | b |
| Move to the next word end | e | e | e |
| Move to the start of the file | gg | gg | gg |
| Move to the end of the file | G | G | G |
| Jump to the matching bracket or parenthesis | % | % | % |
| Jump to the older cursor positionCtrl+i jumps forward through the jump list. | Ctrlo | Ctrlo | Ctrlo |
| Find a character forward on the lineType f then the character. t lands just before it; F and T search backward. | f | f | f |
Editing and registers
Use operators with motions, change or delete text, work with registers, and repeat edits in normal mode.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Delete the current line | dd | dd | dd |
| Delete the character under the cursorX deletes the character before the cursor. | x | x | x |
| Delete from the cursor to line end | D | D | D |
| Change the word under the cursorThe ci text-object pattern also works with parentheses, quotes, and other objects. | ciw | ciw | ciw |
| Change the whole line | cc | cc | cc |
| Change from the cursor to line end | C | C | C |
| Replace one characterType r then the replacement character. | r | r | r |
| Join the current line with the next | J | J | J |
| Copy (yank) the current line | yy | yy | yy |
| Copy text covered by a motionPress y then a motion, such as yw or y$. | y | y | y |
| Paste after the cursorP pastes before the cursor. | p | p | p |
| Undo the last change | u | u | u |
| Redo an undone change | Ctrlr | Ctrlr | Ctrlr |
| Repeat the last change | . | . | . |
| Toggle the case of the character | ~ | ~ | ~ |
| Start character-wise visual mode | v | v | v |
| Start line-wise visual mode | V | V | V |
| Start block-wise visual mode | Ctrlv | Ctrlv | Ctrlv |
| Indent the selected or motion range right | > | > | > |
| Indent the selected or motion range left | < | < | < |
Search, replace, and folds
Search forward or backward, move through matches, replace text, and reveal or hide folded code.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Search forwardType a pattern and press Enter. ? searches backward. | / | / | / |
| Go to the next search matchN goes to the previous match. | n | n | n |
| Search forward for the word under the cursor# searches backward. | * | * | * |
| Clear search highlighting | :nohlsearch | :nohlsearch | :nohlsearch |
| Replace text on the current lineFor example, :s/old/new/g replaces every match on the line. | :s | :s | :s |
| Replace text across the fileFor example, :%s/old/new/g replaces every match in the file. | :%s | :%s | :%s |
| Open or close the fold under the cursor | za | za | za |
| Close the fold under the cursor | zc | zc | zc |
| Open the fold under the cursor | zo | zo | zo |
| Open all folds | zR | zR | zR |
| Close all folds | zM | zM | zM |
Windows, files, and commands
The Ctrl+w prefix manages windows; command-line entries save, quit, edit, and move through files and buffers.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Split the window horizontally | Ctrlws | Ctrlws | Ctrlws |
| Split the window vertically | Ctrlwv | Ctrlwv | Ctrlwv |
| Move to the next window | Ctrlww | Ctrlww | Ctrlww |
| Move to the window on the left | Ctrlwh | Ctrlwh | Ctrlwh |
| Move to the window below | Ctrlwj | Ctrlwj | Ctrlwj |
| Move to the window above | Ctrlwk | Ctrlwk | Ctrlwk |
| Move to the window on the right | Ctrlwl | Ctrlwl | Ctrlwl |
| Close the current window | Ctrlwq | Ctrlwq | Ctrlwq |
| Equalize window sizes | Ctrlw= | Ctrlw= | Ctrlw= |
| Write the current file | :w | :w | :w |
| Quit Vim:wq or :x writes and quits; :q! quits without saving. | :q | :q | :q |
| Write and quit | :wq | :wq | :wq |
| Quit without saving | :q! | :q! | :q! |
| Edit a fileType :e followed by a path, then press Enter. | :e | :e | :e |
| Edit the next buffer | :bn | :bn | :bn |
| Edit the previous buffer | :bp | :bp | :bp |
| Open the command-line prompt | : | : | : |