Vim Keyboard Shortcut Keys: Complete List (With Functions Explained)

Vim is the legendary modal editor that runs everywhere — and in Vim, keyboard keys ARE the interface. This complete list of Vim shortcut keys (commands) explains modes, movement, editing, search and window control in plain words, so a beginner can follow along.

Modes and the Basics

KeyFunction
iEnter Insert mode (before the cursor)
aEnter Insert mode after the cursor (append)
I / AInsert at the start / end of the line
o / OOpen a new line below / above and insert
Esc (or Ctrl + [)Return to Normal mode
vVisual mode (select characters)
VVisual Line mode (select whole lines)
Ctrl + vVisual Block mode (rectangular selection)
uUndo
Ctrl + rRedo
. (dot)Repeat the last change
:wSave (write) the file
:qQuit (fails if there are unsaved changes)
:wq or ZZSave and quit
:q!Quit without saving
ZQQuit without saving (normal mode)
:e filenameOpen/edit another file

Movement Keys

KeyFunction
h / j / k / lMove left / down / up / right
w / WJump forward to the start of the next word / WORD
b / BJump back to the start of a word / WORD
e / EJump to the end of a word / WORD
0Go to the first character of the line
^Go to the first non-blank character of the line
$Go to the end of the line
g_Go to the last non-blank character of the line
ggGo to the first line of the file
GGo to the last line (or {number}G for a specific line)
{ / }Move by paragraph (previous / next blank line)
( / )Move by sentence
%Jump to the matching bracket ( ) { } [ ]
f{char} / F{char}Find a character forward / backward on the line
t{char} / T{char}Move until just before / after a character
; / ,Repeat the last f/F/t/T jump forward / backward
H / M / LMove to the top / middle / bottom of the screen
Ctrl + d / Ctrl + uScroll half a page down / up
Ctrl + f / Ctrl + bScroll a full page forward / back
Ctrl + e / Ctrl + yScroll one line down / up (cursor stays)
zz / zt / zbPut the current line at the center / top / bottom of the screen
* / #Search for the word under the cursor forward / backward
gdGo to the local declaration of the word under the cursor
gfOpen the file whose name is under the cursor

Editing Keys

KeyFunction
x / XDelete the character under / before the cursor
ddDelete (cut) the whole line
dw / d$ (or D)Delete a word / delete to the end of the line
d{motion}Delete with any motion (e.g. d2w, d})
diw / dawDelete the inner word / the word including spaces
di( / di" / di{Delete inside brackets / quotes / braces
ciw / ci"Change (delete + insert) a word / text inside quotes
cc / SChange the whole line
CChange to the end of the line
sSubstitute the character (delete + insert)
r{char}Replace the single character under the cursor
yyYank (copy) the whole line
yw / y$Yank a word / to the end of the line
p / PPaste after / before the cursor
"{a-z}pPaste from a named register
"+y / "+pYank / paste using the system clipboard register
JJoin the next line to the current one
>> / <<Indent / unindent the line
==Auto-indent the line
~Toggle the case of the character
gu{motion} / gU{motion}Make the text lower / UPPER case
Ctrl + a / Ctrl + xIncrement / decrement the number under the cursor
:s/old/new/Substitute on the current line (add /g for all matches)
:%s/old/new/gSubstitute in the whole file

Search, Marks, Windows and Extras

KeyFunction
/patternSearch forward
?patternSearch backward
n / NNext / previous match
:nohClear the search highlighting
m{a-z}Set a mark at the cursor
`{a-z}Jump to a mark (exact position)
''Jump back to the previous jump location
:marksList all marks
q{a-z}Record a macro into a register (press q again to stop)
@{a-z} / @@Play a macro / repeat the last macro
:sp / :vspSplit the window horizontally / vertically
Ctrl + w, then h/j/k/lMove between windows
Ctrl + w, then qClose the current window
:tabnewOpen a new tab
gt / gTNext / previous tab
:bn / :bpNext / previous buffer
:lsList open buffers
Ctrl + ] / Ctrl + tJump to a tag definition / jump back (with ctags)
KLook up the word under the cursor (man page/help)
Ctrl + gShow the file name and position info
:set numberShow line numbers (:set nonumber hides them)
:help {topic}Open Vim's built-in help

Tips for Vim Learners

Vim becomes fast when you think in grammar: verb + number + noun. d (delete) + 2 + w (words) = d2w; c (change) + i + " = rewrite inside quotes. The dot key (.) repeats any change — make one edit, move, press dot. And macros (qa … q, then @a) turn a 100-line cleanup into one recorded sequence. Master hjkl last — the motions above (w, f, %, }) are where the real speed lives.

Frequently Asked Questions

How do I exit Vim?

Press Esc to be in Normal mode, then type :wq and Enter to save and quit, or :q! to quit without saving. ZZ also saves and quits from Normal mode.

How do I copy and paste in Vim?

yy copies the line, p pastes it. For the system clipboard use "+y to copy the selection and "+p to paste (on builds with clipboard support).

How do I replace text in the whole file in Vim?

Use :%s/old/new/g and press Enter — add c (:%s/old/new/gc) to confirm each replacement.

What is the difference between i, a, o in Vim?

i inserts before the cursor, a appends after the cursor, and o opens a brand-new line below (O above) and starts inserting there.

By Umar Farooq, Tech Know.

Post a Comment

0 Comments