While many editors have “hotkeys” that do specific things (like C-c
to copy, C-f
for find), in Vim you typically form commands by composing sentences from verbs and nouns.
You’re probably familiar with the verbs c
(change), d
(delete), and y
(“yank,” i.e. copy), as in dw
means “delete word” (try these with the various nouns if you aren’t already familiar with them). Besides these three basic ones, there are many other such “operators” that function as verbs, including these:
Change case — g~
(for single characters or selections, you can just use ~
as a shorthand)
Lowercase — gu
Uppercase — gU
Auto-indent — =
Decrease, increase indent — < >
Format — gq
(useful for comments in code and collating long wrapped lines)
Just like with c
, d
, and y
, repeating a verb twice “does what you mean,” for instance:<< >>
indent line
⭐️ BONUS handy command:J
join lines — I use this one often!
Sérgio Araújo
gwap will format the paragraph keeping cursor position