VIM MASTERY

Essential shortcuts for developers & ops professionals

M
Mode Switching
i Insert before cursor
a Insert after cursor
o New line below + insert
O New line above + insert
Esc Return to normal mode
v Visual character mode
V Visual line mode
Ctrl+v Visual block mode
Navigation
h j k l ← ↓ ↑ →
w Next word start
b Previous word start
e Word end
0 Line start
$ Line end
gg File start
G File end
% Matching bracket
Selection & Visual
viw Select inner word
vaw Select word + whitespace
vi( Select inside ()
va{ Select around {}
vi" Select inside quotes
vit Select inside HTML tag
gv Reselect last selection
Indentation
>> Indent line right
<< Indent line left
> Indent selection right
< Indent selection left
== Auto-indent line
gg=G Auto-indent entire file
Editing
x Delete character
dd Delete line
dw Delete word
yy Copy line
p Paste after
P Paste before
u Undo
Ctrl+r Redo
J Join lines
Developer Power
* Search word under cursor
# Search backward
gd Go to definition
Ctrl+] Jump to tag
Ctrl+o Jump back
za Toggle fold
zf Create fold
🔍
Search & Replace
/text Search forward
?text Search backward
n Next result
N Previous result
:%s/old/new/g Replace all
:noh Clear highlights
📁
Files & Buffers
:w Save file
:wq Save & quit
:q! Quit without save
:e file Open file
:bn Next buffer
:bp Previous buffer
:ls List buffers
Windows & Tabs
:sp Horizontal split
:vsp Vertical split
Ctrl+w h Move to left split
Ctrl+w l Move to right split
:tabnew New tab
gt Next tab
gT Previous tab
Shell & Commands
:!cmd Execute shell command
:r !cmd Insert command output
K Man page lookup
qa Record macro 'a'
@a Execute macro 'a'
. Repeat last command
Configuration
:set number Show line numbers
:set hlsearch Highlight search
:syntax on Enable syntax
:set tabstop=4 Set tab width
:retab Convert tabs/spaces
💡 Pro Tips
Numbers prefix commands: 5dd deletes 5 lines
Use . to repeat your last action
Visual block mode (Ctrl+v) for column editing
Combine operators: ci" changes inside quotes
Use :help command to learn any Vim feature