Why Vim stays in my toolbox
Whenever I touch servers, configs, or quick scripts, Vim is still the most reliable option. Keeping my hands on the keyboard beats jumping between mouse and shortcuts. This cheat sheet captures the commands I use daily so I don’t lose the muscle memory.
Think in modes
Vim revolves around distinct modes:
- Normal: default mode for navigation and commands.
- Insert: type text with
i,a,o, etc. - Visual: select text via
v(character),V(line), orCtrl+v(block). - Command-line: press
:to save, substitute, run macros.
Hit Esc to return to Normal, then decide your next move.
Opening files and quitting
vim file.txt # open or create
vim . # browse the directory
Essential commands:
:w save
:q quit
:wq save and quit
:q! discard changes
Moving the cursor
Forget the arrow keys—hjkl is faster:
k
h l
j
Extended motions:
w / b / e word-wise jumps
0 / ^ / $ start of line / first non-blank / end of line
<number>gg go to line number
G / gg end / beginning of file
{ / } paragraph navigation
Ctrl+f / Ctrl+b page down / up
Ctrl+e / Ctrl+y scroll by one line
Editing basics
i insert before cursor
a insert after
o open a new line
x delete character
r replace character
R overwrite until Esc
dd delete (copy) the line
dw delete word
u undo
Ctrl+r redo
Visual selections and yanking
yy yank line
p paste
vaw select a word
vab select inside parentheses
vaB select inside braces
v< / v> indent / unindent blocks
v~ / vU / vu toggle case
Pair Visual mode with = to auto-indent code.
Search and replace
/<keyword> search forward, `n` / `N` to cycle
Useful substitutions:
:%s/foo/bar/g replace globally
ggVG :s/foo/bar/g replace within a selection
:%s/foo/bar/gc confirm each replacement
:10,20s/foo/bar/g restrict to lines 10-20
:set number show line numbers temporarily
Minimal .vimrc
Create ~/.vimrc with a handful of tweaks:
syntax on
set number
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set showmatch
set encoding=utf-8
Apply changes instantly via :source ~/.vimrc. Add plugins or advanced settings only after the basics stick.
Practice habits
- Spend 10 minutes a day with
vimtutor. - Force yourself to use
hjklin the terminal. - Write notes in Vim—look up commands only when you are stuck.
Final notes
Vim is approachable once you internalize modes and motions. Invest some time in the fundamentals and the editor becomes a dependable companion on any machine.