CmdKeys LogoCommand Quiz

Vim Keyboard Shortcuts

Vim is a modal editor: you move with motions, change text with operators, and enter insert mode only to type. This track drills those keyboard shortcuts — hjkl, text objects, splits, tabs, search, vimdiff, and quickfix — as real key sequences, not trivia. The same bindings transfer to Neovim and most Vim emulation layers.

Command Reference

motion

CommandDescription
$Move to the end of the current line.
ggGo to the first line of the file.
GGo to the last line of the file (or line number with a count).
wJump to the start of the next word.
bJump to the start of the previous word.
eJump to the end of the current or next word.
jMove the cursor one line down.
kMove the cursor one line up.
0Move to the beginning of the current line.
lMove the cursor one character to the right.
hMove the cursor one character to the left.
WJump to the start of the next WORD (whitespace-delimited).
BJump to the start of the previous WORD (whitespace-delimited).
^Move to the first non-blank character on the line.
Ctrl+fScroll down one screen (page forward).
Ctrl+bScroll up one screen (page backward).
Ctrl+dScroll down half a screen.
Ctrl+uScroll up half a screen.
{Jump to the beginning of the previous paragraph or block.
}Jump to the beginning of the next paragraph or block.
%Jump to the matching bracket, brace, or parenthesis.
f<char>Find the next occurrence of a character on the current line.
;Repeat the last f, F, t, or T motion in the same direction.
HMove to the top line visible on screen.
LMove to the bottom line visible on screen.
geJump to the end of the previous word.
F<char>Find the previous occurrence of a character on the current line.
t<char>Move to just before the next occurrence of a character on the line.
,Repeat the last f, F, t, or T motion in the opposite direction.
|Move to the first column of the current line.
zzCenter the current line in the window.
MMove to the middle line visible on screen.
T<char>Move to just after the previous occurrence of a character on the line.
ztScroll the current line to the top of the window.
zbScroll the current line to the bottom of the window.

insert

CommandDescription
oOpen a new line below and enter insert mode.
EscapeReturn to normal mode from insert or visual mode.
iEnter insert mode before the cursor.
aEnter insert mode after the cursor.
IEnter insert mode at the beginning of the line.
AEnter insert mode at the end of the line.
OOpen a new line above and enter insert mode.
sSubstitute: delete the character under the cursor and enter insert mode.
SDelete the current line and enter insert mode.
giResume insert mode at the last insert position.

ex

CommandDescription
:wqWrite the buffer and quit.
:qQuit the current buffer (fails if there are unsaved changes).
:helpOpen Vim's built-in help documentation.
:wWrite (save) the current buffer to disk.
:set numberShow line numbers in the margin.
:q!Force quit without saving changes.
:e <file>Edit a file in a new buffer, or reload the current file.
:spSplit the window horizontally and edit a file.
:vsSplit the window vertically and edit a file.
:qaClose all files (fails if any buffer has unsaved changes).
:qa!Force quit all files without saving.
:wqaWrite all changed buffers and quit.
:sortSort lines in the current range or whole buffer.
:terOpen a terminal window.

edit

CommandDescription
xDelete the character under the cursor.
ddDelete the current line.
yyYank (copy) the current line.
pPut (paste) the yanked text after the cursor or below the line.
DDelete from the cursor to the end of the line.
ccChange the entire line: delete it and enter insert mode.
CChange from the cursor to the end of the line.
r<char>Replace the character under the cursor with the next typed character.
JJoin the current line with the line below.
PPut (paste) the yanked text before the cursor or above the line.
>>Indent the current line one level to the right.
<<Unindent the current line one level to the left.
.Repeat the last change.
~Toggle the case of the character under the cursor.
REnter Replace mode and overwrite characters as you type.
xpSwap the character under the cursor with the next character.
ddpSwap the current line with the line below.
Ctrl+aIncrement the number under or after the cursor.
Ctrl+xDecrement the number under or after the cursor.
XDelete the character before the cursor.
dwDelete from the cursor to the start of the next word.
"+yYank the current selection or motion into the system clipboard.
&Repeat the last substitute command.
"+pPaste after the cursor from the system clipboard.

tab

CommandDescription
gtGo to the next tab page.
gTGo to the previous tab page.
:tabeOpen a file in a new tab page.
:tabcClose the current tab page.
:taboClose all other tab pages and keep the current one.
:tabsList all tab pages and the windows they contain.

visual

CommandDescription
vStart character-wise visual mode.
VStart line-wise visual mode.
Ctrl+vStart block-wise visual mode.
oIn visual mode, move the cursor to the other end of the selection.
gvReselect the last visual selection.

search

CommandDescription
nGo to the next search match.
/Start a forward search for a pattern.
?Start a backward search for a pattern.
NGo to the previous search match.
*Search forward for the word under the cursor.
#Search backward for the word under the cursor.
:nohClear search highlighting without changing the search pattern.

undo

CommandDescription
uUndo the last change.
Ctrl+rRedo the last undone change.
UUndo all changes on the current line.

textobject

CommandDescription
ciwChange inner word: delete the word under the cursor and enter insert mode.
diwDelete inner word: remove the word under the cursor.
cawChange a word including surrounding whitespace.
dawDelete a word including surrounding whitespace.
ci"Change inside double quotes.
di"Delete inside double quotes.
ci(Change inside parentheses.
disDelete the sentence under the cursor (inner sentence).
dipDelete the paragraph under the cursor (inner paragraph).
cipChange the paragraph under the cursor and enter insert mode.
yipYank the paragraph under the cursor (inner paragraph).
yapYank a paragraph including surrounding blank lines.
ditDelete inside an HTML/XML tag.
citChange inside an HTML/XML tag.
da"Delete a quoted string including the quote characters.

buffer

CommandDescription
:bpGo to the previous buffer.
:bnGo to the next buffer.
:bdRemove the current file from the buffer list.
:lsList all open buffers.
:b <num>Open the buffer with the given number.

fold

CommandDescription
zcClose one fold under the cursor.
zaToggle the fold under the cursor.
zMClose all folds in the buffer.
zROpen all folds in the buffer.
zoOpen one fold under the cursor.

diff

CommandDescription
doObtain the current difference from the other diff buffer.
dpPut the current difference into the other diff buffer.
[cJump to the previous difference in vimdiff.
]cJump to the next difference in vimdiff.
:difRe-scan buffers and refresh vimdiff highlighting.

quickfix

CommandDescription
:copenOpen the quickfix window.
:ccloseClose the quickfix window.
:cnextGo to the next error or location in the quickfix list.
:cpreviousGo to the previous error or location in the quickfix list.
:clistList all errors or locations in the quickfix list.

jump

CommandDescription
Ctrl+oJump to the older position in the jump list.
Ctrl+iJump to the newer position in the jump list.
gfOpen the filename under the cursor.
Ctrl+]Jump to the definition of the tag under the cursor.

case

CommandDescription
gUUUppercase the entire current line.
guuLowercase the entire current line.
gUiwUppercase the word under the cursor.
guiwLowercase the word under the cursor.

marks

CommandDescription
`aJump to the exact position of mark a.
maSet mark a at the current cursor position.
'aJump to the line containing mark a.
:marksList all current marks.
''Jump back to the line of the previous position before the last jump.
``Jump back to the exact previous position before the last jump.

replace

CommandDescription
:s/<pattern>/<str>/gReplace every match on the current line.
:%s/<pattern>/<str>/gReplace every match in the whole file.
:%s/<pattern>/<str>/gcReplace every match in the file, confirming each change.
:g/<pattern>/dDelete every line that matches a pattern.
:v/<pattern>/dDelete every line that does NOT match a pattern.

window

CommandDescription
Ctrl+w sSplit the window horizontally.
Ctrl+w vSplit the window vertically.
Ctrl+w hMove focus to the window on the left.
Ctrl+w jMove focus to the window below.
Ctrl+w kMove focus to the window above.
Ctrl+w lMove focus to the window on the right.
Ctrl+w oClose all other windows and keep only the current one.
Ctrl+w cClose the current window.
Ctrl+w qQuit the current window (same as close when last window).
Ctrl+w wCycle focus to the next window.
Ctrl+w =Make all window heights and widths equal.
Ctrl+w xSwap the current window with the next one.
Ctrl+w _Maximize the current window's height.

macro

CommandDescription
qaStart recording a macro into register a.
qStop recording the current macro.
@aPlay back the macro stored in register a.
@@Repeat the last executed macro.

Key Use Cases

  • Jump a file with word, line, and f/t character motions without the mouse
  • Edit with operators and text objects (change inner word, delete a paragraph, yank quotes)
  • Split windows and tabs to compare files or keep a second buffer visible
  • Search, substitute, and clear highlights without leaving the keyboard
  • Walk vimdiff hunks and compiler errors in the quickfix list

Frequently Asked Questions

What is the difference between a Vim motion and an operator?

A motion only moves the cursor (w, $, %, f). An operator waits for a motion or text object and then acts (d, c, y). dw deletes to the next word; ci" changes inside quotes.

Should I learn hjkl or just use arrow keys?

hjkl keeps your hands on the home row so counts, operators, and repeats stay in one place. This track still names the observable move — left, down, up, right — so either habit can be tested.

Do these shortcuts work in Neovim?

Yes. Motions, operators, text objects, windows, tabs, vimdiff, and quickfix are shared. Neovim-only Lua mappings are not in this dataset.

Why practice :w and ZZ if I already use a GUI save?

Ex commands and normal-mode aliases still matter in a terminal, in vimdiff, and when a plugin drops you in Vim. Muscle memory for :q! / ZQ avoids losing a buffer — or accidentally keeping one.

Ready to master Vim commands?

Test your muscle memory with our spaced-repetition quiz system. Free forever.

Start Practice Now →