Vim Cheatsheet - Editor Command Reference
Essential Vim commands for editing configs on a server. Organized by motion, edit, search, visual mode, and save/exit — just copy and use when stuck.
Back to SysOpsMotion 5
gg / GJump to top / bottom of file
0 / $Jump to start / end of line
w / bForward / backward one word
:42Jump to line 42
Ctrl-f / Ctrl-bPage down / page up
Edit 6
i / aEnter insert mode before / after cursor
o / ONew line below / above and enter insert mode
dd / yyDelete / yank (copy) current line
p / PPaste after / before cursor
u / Ctrl-rUndo / redo
x / r<char>Delete character / replace single character
Search 4
/wordSearch forward for word, n next N previous
:%s/old/new/gReplace all old with new in file
:%s/old/new/gcReplace all with individual confirmation
:nohClear search highlighting
Visual Mode & Save/Exit 6
v / VCharacter-wise / line-wise visual selection
Ctrl-vBlock visual mode for column editing
:wSave
:wq or ZZSave and quit
:q!Force quit without saving
:w !sudo tee %Force save when forgot sudo
💡 Tips
- Stuck in Vim? Press Esc to return to Normal mode, then type :q! to force quit without saving.
- Forgot sudo when editing a system file? Use :w !sudo tee % to save with elevated privileges without reopening.
- Before a large substitution, use /word to confirm matches, then :%s — add the c flag to confirm each replacement.