vim
10 commands
10 shown
Save and quit
Write file and quit vim
:wq
Quit without saving
Force quit discarding all changes
:q!
Global search and replace
Replace all occurrences interactively (c = confirm)
:%s/old/new/gc
Open file at line number
Start vim with cursor on line 42
vim +42 file.txt
Search forward / backward
/ searches forward, ? searches backward; n/N cycle results
/pattern (n/N next/prev)
?pattern (backward)
Delete lines matching pattern
Delete all lines starting with # (comment lines)
:g/^#/d
Re-indent whole file
Go to top (gg), re-indent to end of file (=G)
gg=G
Record and play macro
Macros automate repetitive edits in vim
qa (record into a)
q (stop)
@a (play)
10@a (play 10 times)
Show line numbers
Toggle line numbers on (use :set nonumber to hide)
:set number
Split window and open file
Vertical split; use Ctrl-w + arrow to navigate panes
:vsplit other.txt
no commands match