Thursday, June 7, 2012

Tips On Getting Started With Vim

My primary text editor is Vim. I've got it installed on every nearly system that I use. It's a great editor, and it boosts my productivity by a considerable amount.

One major downside to Vim is that it is very difficult to learn. I've been using it for many years, and I have some advice for those getting started with Vim.

Go Through Vimtutor Multiple Times

I think that Vim is best learned by doing. Many of the major key bindings make sense and can easily be memorized ('i' is short for insert, 'a' is short for append, 'x' is delete), but getting proficient at Vim requires muscle memory.

Vim comes with a hands-on tutorial called Vimtutor. Here's how you can start it:

Windows: The installer adds a start-menu shortcut named 'Vim tutor' in the Vim <Version_Number> folder. If you're on Windows Vista or 7, just type 'vim tutor'.

Mac OSX and Linux: Type 'vimtutor' in a terminal window.

Vimtutor doesn't cover all aspects of vim (like recording what you type and playing it back), but it does a great job of going over the basics. If you go through the tutorial a few times, you should have a good grasp of the basics and should be ready to use it for most of your day-to-day text editing needs.

Consider Not Completely Switching to Using Vim At First

I think that, for many people out there, the best approach to switching to Vim is a gradual one. Productivity is bad when you first start using Vim because it behaves like no other text editor (except for VI and other VI-like editors).  If you have due dates to meet and bugs to fix, switching exclusively to Vim is probably a bad idea until you get used to the basics.

Don't Be Afraid To Give Up (And Try Again)

Vim is complicated and weird. It's my kind of text editor, but it is not for everyone.

If you've tried the first few vimtutor tutorials and still struggle getting through them, considering using another text editor for a while. Notepad++, gedit, and Sublime Text 2 are excellent text editors that don't require weeks and months of memorization to use. After taking a long break, you can always go back to Vim and try the tutorials again.