Unearthing the Treasure Trove of Vim: A Guide to the Most Obscure and Useless Commands in the Land of the Text Editor
I saw some Vim commands that would really help me out to remember.
Scope with ({["
Chain these commands with a symbol to change within a scope.
i
- inside scope - exclusive inner match
Match all text inside brackets / symbols.
ci{
- delete all text inside{}
scope and enter insert modedi(
- delete all text inside()
scopeyi[
- yank all text inside[]
scopevi"
- select all text inside""
scope
a
- scope to matching symbol - inclusive inner match
Similar to i
, but also selects the matching brackets / symbols.
ca{
- delete all text inside{}
scope and enter insert modeda(
- delete all text inside()
scopeya[
- yank all text inside[]
scopeva"
- select all text inside""
scopeap
matches “around paragraph”ip
matches “in paragraph”
In the above examples, p
can be replaced with any vim object. A word, ”, ’, (, {, [, etc. And a command can be chained at the beginning:
vap
select a whole paragraph and surrounding linesvip
select all text in a paragraphva"
select all text and surrounding quotesvi"
select all text inside quotesdi(
delete all text inside()
ci{
change all text inside{}
ya[
yank all text and surrounding[]
g
- jump to
gi
- jump to last insertgv
- jump to last selection
Misc
gq
- add line breaks to selected text that exceeds the delimiter~
- capitalizeguaw
- lowercase the word under the cursorgUaw
- uppercase the word under the cursorguu
- lowercase linegUU
- uppercase line
I use ciw
for replacing words all the time already, but I didn’t know I could select stuff from within a bigger scope. That will be really useful.
ZQ
force quitZZ
save quitzz
shift current line to middle of screenzt
shift current line to top of screenzb
shift current line to bottom of screen{
move up a paragraph}
move down a paragraph
I think none of these are particularly useful for me except maybe ZZ
. I still have a habit of :wq
ctrl+g
show information about the filegj
move down visual line on a wrapped linegk
move up visual line on a wrapped lineg0
move to beginning of visual line on a wrapped lineg$
move to beginning of visual line on a wrapped line~
change capitalization of a letterg~
same as~
but runs on a text objectgf
jump to filename under cursorgj
Join lines without adding spaces betweeng&
repeat substitution across fileg*
or*
jumps to the next instance of the word under the cursor.g#
jumps to the previous instance of the word under the cursor.
While in insert mode enter C-k
to insert a special character.
Use :digraph
to see a chart of special characters and their key combinations.