Cheat sheets / Vim
Vim Cheat Sheet
The 72 Vim commands that take you from stuck to comfortable, grouped by what you are doing. Type in the filter to find one fast.
This page also works as a hotkey overlay. Hold Ctrl+Space to see it, let go to hide it. What is this?
Modes
- Insert before the cursor i
- Insert after the cursor a
- New line below / above o/O
- Back to normal mode Esc
- Select characters / lines v/V
- Select a block Ctrl+v
Save and quit
- Save :w
- Quit :q
- Save and quit :wq
- Quit without saving :q!
- Save and quit, no colon ZZ
- Open another file :ename
Move
- Left, down, up, right h/j/k/l
- Next / previous word w/b
- Start / end of line 0/$
- Top / bottom of file gg/G
- Go to line 42 42G
- Half a page down / up Ctrl+d/u
Jump
- To the next x on the line fx
- Repeat that jump ;
- Previous / next paragraph {/}
- To the matching bracket %
- Back / forward in jumps Ctrl+o/i
- Center the screen on the cursor zz
Edit
- Delete a character x
- Delete the line dd
- Delete to the next word dw
- Change to the end of the word cw
- Replace one character r
- Join the next line onto this one J
Copy, paste, undo
- Copy the line yy
- Copy a word yw
- Paste after / before p/P
- Undo u
- Redo Ctrl+r
- Repeat the last change .
Search
- Search forward /text
- Search backward ?text
- Next / previous match n/N
- Search the word under the cursor *
- Clear the highlighting :noh
- Switch upper / lower case ~
Replace
- First match on the line :s/old/new/
- Every match on the line :s/old/new/g
- Every match in the file :%s/old/new/g
- Same, asking each time :%s/old/new/gc
- Type over existing text R
- Replace the whole line cc
Text objects
- Change the word ciw
- Change inside the quotes ci"
- Delete inside the parentheses di(
- Copy the paragraph yip
- Delete the paragraph dap
- Select inside the HTML tag vit
With a selection
- Indent / unindent >/<
- Fix the indentation =
- Copy y
- Delete d
- Select the same area again gv
- Block mode: insert on every line I
Windows and tabs
- Split below / beside :sp/:vsp
- Go to the next window Ctrl+ww
- Close the window Ctrl+wq
- New tab :tabnew
- Next / previous tab gt/gT
- List open files :ls
Macros and marks
- Start recording into a qa
- Stop recording q
- Play macro a @a
- Play the last macro again @@
- Set mark a here ma
- Jump to mark a 'a
No commands match .
Stuck? Press Esc, then type :q! and Enter to leave without saving. Commands are case-sensitive: G and g are different keys. All of this also works in Neovim and in the Vim mode of VS Code and JetBrains editors.
Keep this cheat sheet on a hotkey
BrainRAM is a small free app for Windows. Hold Ctrl+Space and this page appears on top of whatever you are doing. Let go and it's gone. Glance, let go, carry on.
Every group sits in the same place each time, so after a few days you stop reading and just glance at the spot.
- Download BrainRAM Free, no account, works offline. The installer isn't code-signed yet, so Windows shows a blue warning: click More info, then Run anyway.
- Add this page to BrainRAM Opens BrainRAM with this page ready to import.
BrainRAM runs on Windows today. The macOS and Linux versions are on the way.
Email me when mine is ready