I’ve noticed that people older than me have always known just a few more vi commands than I do.
I’m in my 40s, so clearly I know about 4:
Writes and quits (I consider these variants of the same thing):
:w
:q
:q!
:wq
ZZ
See the line numbers:
:set number
Delete everything from top to bottom (must be at top, easily remembered by mumbling duck, duck, duck, GOOSE):
:dddG
Search for a string:
/
And that’s probably it. I think I used to know how to cut a line and paste a line, but I’d have to look it up to be 100% correct on the syntax.
Anyone in their 50s or 60s care to add to this dazzlingly long list of inadequacy? Not looking for a cheat sheet or the man page :-p
:%s for changing a string on the entire file (I think it also works with selections instead of entire file)
:m+{num} to move a line
:tabe to open another tab (not split)
:te open terminal
:wqa write and quit all buffers (will fail with non-writrable buffer, like a terminal, sadly)
:!{shell command} execute
:r!{shell command} execute and write to current buffer
:cd change directory
Not a command, but useful to remember
%
means current file (eg. :!rm %)I’m 19, and the plan is to learn all before 200