Vim keyboard shortcuts
Vim is the modal text editor found on almost every Unix system. Most commands are plain keys typed in Normal mode: these move, edit, search, save and split windows.
Most used Vim keyboard shortcuts
The Vim shortcuts worth learning first. The full list follows, grouped by task.
- Return to Normal modeMacEscorCtrl[WindowsEscorCtrl[LinuxEscorCtrl[
- Insert before the cursorMacIWindowsILinuxI
- Save the fileMacShift;,W,EnterWindowsShift;,W,EnterLinuxShift;,W,Enter
- QuitMacShift;,Q,EnterWindowsShift;,Q,EnterLinuxShift;,Q,Enter
- Save and quitMacShiftZ,ShiftZWindowsShiftZ,ShiftZLinuxShiftZ,ShiftZ
- Delete (cut) the lineMacD,DWindowsD,DLinuxD,D
- Copy (yank) the lineMacY,YWindowsY,YLinuxY,Y
- Paste after the cursorMacPWindowsPLinuxP
- UndoMacUWindowsULinuxU
- RedoMacCtrlRWindowsCtrlRLinuxCtrlR
- Search forwardMac/Windows/Linux/
- Go to the last lineMacShiftGWindowsShiftGLinuxShiftG
Modes
11 shortcuts| Action | Mac | Windows | Linux |
|---|---|---|---|
| Insert before the cursorNormal mode | I | I | I |
| Append after the cursorNormal mode | A | A | A |
| Insert at the start of the lineNormal mode | ShiftI | ShiftI | ShiftI |
| Append at the end of the lineNormal mode | ShiftA | ShiftA | ShiftA |
| Open a new line below and insertNormal mode | O | O | O |
| Open a new line above and insertNormal mode | ShiftO | ShiftO | ShiftO |
| Return to Normal modeInsert or Visual mode | EscorCtrl[ | EscorCtrl[ | EscorCtrl[ |
| Start Visual mode (select characters)Normal mode | V | V | V |
| Start Visual Line mode (select lines)Normal mode | ShiftV | ShiftV | ShiftV |
| Start Visual Block mode (select a column)Normal mode | CtrlV | CtrlV | CtrlV |
| Start Replace mode (overtype)Normal mode | ShiftR | ShiftR | ShiftR |
Moving
25 shortcutsEditing
22 shortcuts| Action | Mac | Windows | Linux |
|---|---|---|---|
| UndoNormal mode | U | U | U |
| RedoNormal mode | CtrlR | CtrlR | CtrlR |
| Delete the character under the cursorNormal mode | X | X | X |
| Delete (cut) the lineNormal mode | D,D | D,D | D,D |
| Delete to the end of the lineNormal mode | ShiftD | ShiftD | ShiftD |
| Delete to the start of the next wordNormal mode | D,W | D,W | D,W |
| Change (replace) the wordNormal mode | C,W | C,W | C,W |
| Change the whole lineNormal mode | C,C | C,C | C,C |
| Change to the end of the lineNormal mode | ShiftC | ShiftC | ShiftC |
| Delete the character and insertNormal mode | S | S | S |
| Copy (yank) the lineNormal mode | Y,Y | Y,Y | Y,Y |
| Copy (yank) to the next wordNormal mode | Y,W | Y,W | Y,W |
| Paste after the cursorNormal mode | P | P | P |
| Paste before the cursorNormal mode | ShiftP | ShiftP | ShiftP |
| Join the line below to this oneNormal mode | ShiftJ | ShiftJ | ShiftJ |
| Repeat the last changeNormal mode | . | . | . |
| Indent the lineNormal mode | Shift.,Shift. | Shift.,Shift. | Shift.,Shift. |
| Outdent the lineNormal mode | Shift,,Shift, | Shift,,Shift, | Shift,,Shift, |
| Switch the case of the characterNormal mode | Shift` | Shift` | Shift` |
| Add one to the number under the cursorNormal mode | CtrlA | CtrlA | CtrlA |
| Subtract one from the number under the cursorNormal mode | CtrlX | CtrlX | CtrlX |
| Complete the word from the fileInsert mode | CtrlN | CtrlN | CtrlN |
Search
6 shortcuts| Action | Mac | Windows | Linux |
|---|---|---|---|
| Search forwardNormal mode | / | / | / |
| Search backwardNormal mode | Shift/ | Shift/ | Shift/ |
| Next matchNormal mode | N | N | N |
| Previous matchNormal mode | ShiftN | ShiftN | ShiftN |
| Search for the word under the cursorNormal mode | Shift8 | Shift8 | Shift8 |
| Search backward for the word under the cursorNormal mode | Shift3 | Shift3 | Shift3 |
Files and windows
9 shortcuts| Action | Mac | Windows | Linux |
|---|---|---|---|
| Save the fileNormal mode | Shift;,W,Enter | Shift;,W,Enter | Shift;,W,Enter |
| QuitNormal mode | Shift;,Q,Enter | Shift;,Q,Enter | Shift;,Q,Enter |
| Save and quitNormal mode | ShiftZ,ShiftZ | ShiftZ,ShiftZ | ShiftZ,ShiftZ |
| Quit without savingNormal mode | ShiftZ,ShiftQ | ShiftZ,ShiftQ | ShiftZ,ShiftQ |
| Split the window horizontallyNormal mode | CtrlW,S | CtrlW,S | CtrlW,S |
| Split the window verticallyNormal mode | CtrlW,V | CtrlW,V | CtrlW,V |
| Go to the next windowNormal mode | CtrlW,W | CtrlW,W | CtrlW,W |
| Close the windowNormal mode | CtrlW,Q | CtrlW,Q | CtrlW,Q |
| Make all windows the same sizeNormal mode | CtrlW,= | CtrlW,= | CtrlW,= |
No shortcuts match. Try fewer words, the key names only, or search every app.
Show the key map: which keys Vim uses mostDarker orange = used by more shortcuts
Move around in Vim: end of line, top and end of file
- Move leftMacHWindowsHLinuxH
- Move downMacJWindowsJLinuxJ
- Move upMacKWindowsKLinuxK
- Move rightMacLWindowsLLinuxL
- Jump to the start of the next wordMacWWindowsWLinuxW
- Jump back to the start of the wordMacBWindowsBLinuxB
- Jump to the end of the wordMacEWindowsELinuxE
- Go to the start of the lineMac0Windows0Linux0
- Go to the first non-blank characterMacShift6WindowsShift6LinuxShift6
- Go to the end of the lineMacShift4WindowsShift4LinuxShift4
- Go to the first lineMacG,GWindowsG,GLinuxG,G
- Jump to the matching bracketMacShift5WindowsShift5LinuxShift5
- Jump to the next blank lineMacShift]WindowsShift]LinuxShift]
- Jump to the previous blank lineMacShift[WindowsShift[LinuxShift[
- Cursor to the top of the screenMacShiftHWindowsShiftHLinuxShiftH
- Cursor to the middle of the screenMacShiftMWindowsShiftMLinuxShiftM
- Cursor to the bottom of the screenMacShiftLWindowsShiftLLinuxShiftL
- Scroll a page downMacCtrlFWindowsCtrlFLinuxCtrlF
- Scroll a page upMacCtrlBWindowsCtrlBLinuxCtrlB
- Scroll half a page downMacCtrlDWindowsCtrlDLinuxCtrlD
- Scroll half a page upMacCtrlUWindowsCtrlULinuxCtrlU
- Center the cursor line on screenMacZ,ZWindowsZ,ZLinuxZ,Z
- Jump back to the previous positionMacCtrlOWindowsCtrlOLinuxCtrlO
- Jump forward againMacCtrlIWindowsCtrlILinuxCtrlI
- Go to a line number
- Type the number and G, such as 42G, or :42 and Enter.
Delete, copy and paste in Vim
- Delete the character under the cursorMacXWindowsXLinuxX
- Delete to the end of the lineMacShiftDWindowsShiftDLinuxShiftD
- Delete to the start of the next wordMacD,WWindowsD,WLinuxD,W
- Change (replace) the wordMacC,WWindowsC,WLinuxC,W
- Change the whole lineMacC,CWindowsC,CLinuxC,C
- Change to the end of the lineMacShiftCWindowsShiftCLinuxShiftC
- Delete the character and insertMacSWindowsSLinuxS
- Copy (yank) to the next wordMacY,WWindowsY,WLinuxY,W
- Paste before the cursorMacShiftPWindowsShiftPLinuxShiftP
- Join the line below to this oneMacShiftJWindowsShiftJLinuxShiftJ
- Repeat the last changeMac.Windows.Linux.
- Indent the lineMacShift.,Shift.WindowsShift.,Shift.LinuxShift.,Shift.
- Outdent the lineMacShift,,Shift,WindowsShift,,Shift,LinuxShift,,Shift,
- Switch the case of the characterMacShift`WindowsShift`LinuxShift`
- Add one to the number under the cursorMacCtrlAWindowsCtrlALinuxCtrlA
- Subtract one from the number under the cursorMacCtrlXWindowsCtrlXLinuxCtrlX
- Complete the word from the fileMacCtrlNWindowsCtrlNLinuxCtrlN
- Delete every line
- In Normal mode, gg then dG deletes from the first line to the last; :%d and Enter does the same.
- Select all and copy
- ggVG selects the whole file; then y copies it. To copy to the system clipboard, use "+y (Vim must be built with clipboard support).
- Comment lines
- Plain Vim has no comment key. Select lines with Ctrl+V, press I, type # or // and press Esc to add it to every line; plugins such as vim-commentary add gcc.
Vim modes: insert, visual and replace
- Append after the cursorMacAWindowsALinuxA
- Insert at the start of the lineMacShiftIWindowsShiftILinuxShiftI
- Append at the end of the lineMacShiftAWindowsShiftALinuxShiftA
- Open a new line below and insertMacOWindowsOLinuxO
- Open a new line above and insertMacShiftOWindowsShiftOLinuxShiftO
- Start Visual mode (select characters)MacVWindowsVLinuxV
- Start Visual Line mode (select lines)MacShiftVWindowsShiftVLinuxShiftV
- Start Visual Block mode (select a column)MacCtrlVWindowsCtrlVLinuxCtrlV
- Start Replace mode (overtype)MacShiftRWindowsShiftRLinuxShiftR
Search and replace in Vim
- Search backwardMacShift/WindowsShift/LinuxShift/
- Next matchMacNWindowsNLinuxN
- Previous matchMacShiftNWindowsShiftNLinuxShiftN
- Search for the word under the cursorMacShift8WindowsShift8LinuxShift8
- Search backward for the word under the cursorMacShift3WindowsShift3LinuxShift3
- Replace in the whole file
- :%s/old/new/g and Enter replaces every match; add c (:%s/old/new/gc) to confirm each one.
Save, quit and split windows in Vim
- Quit without savingMacShiftZ,ShiftQWindowsShiftZ,ShiftQLinuxShiftZ,ShiftQ
- Split the window horizontallyMacCtrlW,SWindowsCtrlW,SLinuxCtrlW,S
- Split the window verticallyMacCtrlW,VWindowsCtrlW,VLinuxCtrlW,V
- Vim keys in VS Code and other apps
- The Vim extension for VS Code, IdeaVim for JetBrains IDEs, and the built-in Vim modes in Zed and Obsidian accept these same keys.
Vim keyboard shortcuts: questions
- How do I exit Vim?
- Press Esc to get back to Normal mode, then type :q and press Enter. Use :q! to quit without saving, or :wq (or ZZ) to save and quit.
- Why do Vim keys type letters instead of running commands?
- You are in Insert mode. Press Esc to return to Normal mode, where letters are commands; press i to go back to typing.
These are the default key bindings in Vim 9.1, as published by Bram Moolenaar and the Vim community. Shortcuts that need an extension, an add-in or a changed keymap are left out. Where two combinations do the same thing, both are shown.
Single-system lists: Vim keyboard shortcuts for Mac, Vim keyboard shortcuts for Windows, Vim keyboard shortcuts for Linux.
Each shortcut has its own page with the keys for every system, related shortcuts and the same action in other apps. The printable cheat sheet fits the whole list on one or two pages.