Some smart commands that made a huge difference in my day to day usage with vim:
ciw ---------> change the current word (It's different than cw as you can be everywhere in the word while typing the command and it will delete all the word and let you retype it). Also, there's di), da), di], da], ci", ca" which are all similar but extremely useful.
. -----------> Repeat the last command. Useful when you don't feel like writing a macro but still don't want to retype the command again and again. For instance, instead of dwdwdwdw, dw...... (Yes, I know that in an ideal world, you'd just use a smarter d<command> but sometime you start with dw without thinking too much.)
Also, I tend to use "v" (for visual mode) a lot. For instance, for some reason, I use Vd to delete the line. (Select the whole line delete). I like this approach because I like to incrementally change things. I.e. If I want to remove some lines, I don't do 3dd as I'd have to think beforehand "I've got three lines to delete". I usually do: Vjjjd (I.e. select the first line, select the 2 after and delete).
There're so much great gems that I've discovered during the years, maybe a last one..:
= ---> Reindent.. So, as explained in the last paragraph, I'd usually go Vjjjjjj% to select a region and indent it. Note that I've remapped J as 4j instead of join-lines so I can select multiple lines with J.. thus:
VJJ% would indent the actual + 8 next lines.
ciw ---------> change the current word (It's different than cw as you can be everywhere in the word while typing the command and it will delete all the word and let you retype it). Also, there's di), da), di], da], ci", ca" which are all similar but extremely useful.
. -----------> Repeat the last command. Useful when you don't feel like writing a macro but still don't want to retype the command again and again. For instance, instead of dwdwdwdw, dw...... (Yes, I know that in an ideal world, you'd just use a smarter d<command> but sometime you start with dw without thinking too much.)
Also, I tend to use "v" (for visual mode) a lot. For instance, for some reason, I use Vd to delete the line. (Select the whole line delete). I like this approach because I like to incrementally change things. I.e. If I want to remove some lines, I don't do 3dd as I'd have to think beforehand "I've got three lines to delete". I usually do: Vjjjd (I.e. select the first line, select the 2 after and delete).
There're so much great gems that I've discovered during the years, maybe a last one..:
= ---> Reindent.. So, as explained in the last paragraph, I'd usually go Vjjjjjj% to select a region and indent it. Note that I've remapped J as 4j instead of join-lines so I can select multiple lines with J.. thus: VJJ% would indent the actual + 8 next lines.