Some of my favorite VIM moves

I’ve been using VIM as my IDE for a few years now. I love it, it’s just so flexible, and you never run out of cool tricks to pick up. Here are a few of my favourites

1. Auto format code

Make a selection and press =

2. Search for the word under the cursor

Just press * with cursor in a word

3. Add or subtract a value to or from the next number in line

3 ctrl + a Add 3 to next number
6 ctrl + x Remove 6 from next number

4. Mark a location to go back to later

mx mark x
my mark y
`x go back to x
'y go back to the line y is on

5. Record a Macro

Record a sequence of input and play it back.
qw start recording a macro called w
q stop recording
@w playback the w macro
:5, 10norm! @w Run the w macro on lines 5 - 10
:%norm! @w Run the w macro on all lines

6. Multi-line insert

ctrl + v to enter column select mode. Then move the cursor up or down to select some lines. Press I and type whatever you want, then exit insert mode to apply

7. Change in, Select in

I guess this is just standard vim stuff, but these combinations are very useful

Replace text in the closest containing (), [], html tag, " etcetera
cit change in tag
ci( change in (
ci" change in "

Select text in the closest containing item
vi{ select in {
vw" select in the current word

One thing I like doing quite often is selecting everything in a {} block and folding it. vi{zf. I might even create a macro to do that so I can fold a bunch of block quickly, that would be qwvi{zfq, then @w to execute.