Source: this video by typecraft
- quit:
:q,:wqto write and quit,:xdoes similar,:q!quits without saving,:wq!forces overwrite - search and replace:
:s/hello/world,:s/hello/world/g,:s@hello@wor/ld@g- Read up on vim regular expressions.
- search:
/regexsearch forward;?regexsearch backwards;nto go to next match (forward with/, backward with?),Nto go in the opposite direction. - motions:
ciw= change in word,cw= change to end of word,caw= change around word,ciW= change in word.- words:
wvsWis syntactic vs whitespace, so e.g.wwill seehello+worldas two words, sociwwithinhellowould replacehello, whereasWwill seehello+worldas one word, sociWwill change all ofhello+world. - delimiters:
b= parens,B= braces;{,<,(,[,',"and also for backquotes
- words:
- visual:
vto select characters,Vto select rows,<C-v>to select columns (i.e. rectangular block)- yank:
ywill copy whatever is selected,"qywill copy whatever is selected to registerq - change:
cwill change whatever is selected - delete:
dwill delete whatever is selected and put it in the default register (so is kind of 'cut')
- yank:
- registers:
- yank, delete, put:
"qyyanks to registerq,"wdcut to registerw,"epput after from registere
- yank, delete, put:
- macros:
- record:
qa...keysqrecords a macro into registera - replay:
@awill run macroa,10@awill run macroaten times
- record: