Vim cheat sheet
The 94 commands the course teaches, by task. Each is checked in Vim.
Move around
- hjklLeft, down, up, right.Modes, movement and a first edit
- wNext word.Choose a word destination
- eEnd of the word.Choose a word destination
- bBack to the start of a word.Choose a word destination
- WNext WORD: skips punctuation, stops after spaces.Read punctuation as word or WORD
- EEnd of the WORD.Read punctuation as word or WORD
- BBack to the start of a WORD.Read punctuation as word or WORD
- 0Start of the line.Reach a line or buffer boundary
- ^First character that is not a space.Reach a line or buffer boundary
- $End of the line.Reach a line or buffer boundary
- ggFirst line.Reach a line or buffer boundary
- GLast line.Reach a line or buffer boundary
- 3GLine 3.Reach a line or buffer boundary
- f,Jump to the next comma on the line (any character works).Find a character boundary
- t,Jump to just before it.Find a character boundary
- F,Jump back to the previous comma.Find a character boundary
- T,Jump back to just after it.Find a character boundary
- ;Repeat the last f, t, F or T.Repeat and reverse a character search
- ,Repeat it the other way.Repeat and reverse a character search
- 2f|Jump to the second | on the line.Repeat and reverse a character search
- %The matching bracket.Match nested delimiters
- d%Delete to the matching bracket, brackets included.Match nested delimiters
- }Next blank line between paragraphs.Use paragraph boundaries
- {Previous blank line between paragraphs.Use paragraph boundaries
- Ctrl-oBack to where you were before a jump.Leave and return deliberately
- Ctrl-iForward again.Leave and return deliberately
- maSet mark a here.Leave and return deliberately
- `aReturn to mark a, to the exact column.Leave and return deliberately
Start typing
- iInsert before the cursor.First edits and modes
- aInsert after the cursor.Choose where typing begins
- IInsert at the start of the line's text.Choose where typing begins
- AInsert at the end of the line.Choose where typing begins
- oNew line below.Choose where typing begins
- ONew line above.Choose where typing begins
- EscBack to Normal mode. Also cancels a command you have started.First edits and modes
Delete and change
- xDelete one character.First edits and modes
- rReplace one character with the next one you type.First edits and modes
- dwDelete to the next word.Compose an edit
- deDelete to the end of the word.Compose an edit
- cwChange to the end of the word.Compose an edit
- ddDelete the line.Compose an edit
- ccChange the line.Compose an edit
- 3xDelete three characters.Count a known region
- 2ddDelete two lines.Count a known region
- d2wDelete two words. 2dw does the same.Count a known region
- ciwChange the word under the cursor.Edit a whole word
- diwDelete the word, keep the spaces.Edit a whole word
- dawDelete the word and one space.Edit a whole word
- ci"Change the text inside double quotes.Keep the quotation
- di"Empty the quotes.Keep the quotation
- ci(Change the text inside round brackets.Choose the whole pair
- ca(Change the brackets and what they hold.Choose the whole pair
- ci[Change inside square brackets.Choose the whole pair
- ci{Change inside curly brackets.Choose the whole pair
- ci'Change inside single quotes.Choose the whole pair
- d/textDelete up to a search match. Press Enter after the text.Make search part of an edit
- c/textChange up to a search match.Make search part of an edit
- dipDelete the paragraph, keep the blank line.Use paragraph boundaries
- dapDelete the paragraph and a blank line.Use paragraph boundaries
- citChange inside an HTML element.Optional: markup objects
- catChange the element, tags included.Optional: markup objects
Copy and put
- yyCopy the line.Compose an edit
- pPut after the cursor, or below the line.Compose an edit
- PPut before the cursor, or above the line.Copy and move text
- yiwCopy the word.Copy and move text
- "0pPut your last copy, even after a delete.Protect a useful copy
- "_ddDelete a line without replacing your copy.Protect a useful copy
- "ayyCopy the line into register a.Protect a useful copy
- "apPut from register a.Protect a useful copy
Undo
- uUndo the last change.Recover and cancel
- Ctrl-rRedo it.Recover and cancel
Search
- /textSearch forward. Press Enter to go.Search for a destination
- ?textSearch backward.Search for a destination
- nNext match.Inspect and reuse a search
- NPrevious match.Inspect and reuse a search
- *Search for the word under the cursor.Inspect and reuse a search
- #The same, backward.Inspect and reuse a search
Repeat
- .Repeat the last change.Build one repeatable change
- cgnChange the next search match; . changes the one after.Search, change, inspect, repeat
- qaRecord a macro into register a. Press q to stop.Record, stop and replay
- @aPlay macro a.Record, stop and replay
- @@Play the last macro again.Record, stop and replay
- 3@aPlay macro a three times.Make replay robust
Select
- vSelect characters. Move to grow the selection.Select when a shape needs inspection
- VSelect whole lines.Select when a shape needs inspection
- Ctrl-vSelect a block of columns.Edit a rectangle
- Ctrl-v…IType at the left edge of every selected line, then Esc.Edit a rectangle
- Ctrl-v…$AType at the end of every selected line, then Esc.Edit a rectangle
Reshape
- JJoin the next line to this one.Reshape without retyping
- >>Indent the line.Reshape without retyping
- gUiwMake the word upper case.Reshape without retyping
- Ctrl-aAdd one to the number at or after the cursor.Optional: numeric changes
- Ctrl-xSubtract one.Optional: numeric changes
- 3Ctrl-aAdd three.Optional: numeric changes
Dojo Vim · dojovim.com/cheat-sheet/