Brendan Dawes
The Aesthetics of Form and Code

My Most Used Day-to-Day Vim Features

When you first starting using Vim as your default editor the amount of things to learn can be overwhelming. I've been using Vim for about a year now and after a while things become like muscle memory, even though I'm still learning new things Vim can do every day. There are though some things I use more than others, that have become second-place to me in my daily usage of Vim. Here's a few of them.

o go into insert mode below current line.

O go into insert mode above current line.

g g = G auto-indent the whole buffer.

g i jump back to the last place you were editing and go into insert mode.

z z center the current line.

/ search forward.

? search backward.

c i " change inside quotes.

* search for current word under cursor.

Ctrl + ] jump to method definition (requires ctag file).

~ toggle case.

Ctrl + o go back through the jump list. Do this twice when opening a file to bring up where you last where.

Ctrl + i go forward through the jump list.

I enter Insert mode at the beginning of the line.

A enter Insert mode at the end of the line.

g f open file under cursor.

Navigating files with NETRW. When I first started using Vim I read many articles that said to use NerdTree to create a project drawer style file browser. However when you start using splits you realise that it no longer makes sense, as pointed out in this great article. Using the built-in plugin NETRW means you can instead navigate files using a much better "card flipping" metaphor. I have triggering NETRW mapped to CTRL-n in my .vimrc like this:

map <c-n> :edit .<CR>

When I press CTRL-n it will bring up the file browser in the same split as my current buffer. To flip back I just press CTRL-^. When using NETRW I can move back through directories with - and create new directories with d. I can create a new file by pressing %. I use this now as the default way to navigate around a project.

These are just a few of the things I use everyday with Vim. I've stayed away from talking about some of the plugins I use (I try not to use that many), but hopefully this might have proved useful to some, and if you haven't already it may make you want to switch to Vim, which I highly recommend.