How to Learn Vim

Vim is a powerful text editor, but is has a moderate learning curve that scares some programmers away.  Hardcore vimmers think it is best to throw out your mouse, disable your navigation arrow keys, and be completely unproductive for 2-3 weeks as you learn the text editor.  Others think it is better to install MacVim, a library with the core Vim plugins (i.e. Janus), and gradually learn.  Yehuda Katz outlined a gradual approach in a blog post and I am building on his start with a learning approach that is even more gentle.

Start by Learning Vimium, a Chrome Plugin

Vimium is a Chrome plugin that provides access to basic Vim key bindings for web browsing.  After Vimium is installed, you can use j and k to scroll up and down, gg and G to go the top and bottom of the page, / to find words, n and N to scroll through the worst, and f to pop up 1-3 character sequences that click a link.  All the regular Chrome shortcuts still work with Vimium.  Navigating the internet without a mouse and learning basic Vim key bindings is a perfect way to get your feet wet.

Study Vim for 2-3 Hours Before Using it the First Time

Vim’s modes are a paradigm shift for programmers coming from a life of TextMate, Sublime Text, and Microsoft Word.  Don’t read a book on Vim before picking it up, but make sure to read Yehuda’s article, ThoughtBot’s wisdom, and work through vimtutor while taking detailed notes.  I realized the power of Vim just a few examples into Vim tutor and the new text editing methodology felt right.

Use MacVim and Janus

MacVim is more forgiving that Terminal Vim as it permits standard text editor actions like Command + S and Janus is a distribution of plugins that makes it easier to work with Vim.  Janus includes Ack that lets you grep recursively through a directory, a plugin that lets you navigate to a file with Command + T, NerdTree to view a file directory of your project, and Syntastic to notify you of unnecessary variables and syntax errors.  NerdTree is important, so it is worthwhile to type :help NERDtree and read about the basic commands.

Always Leave the Cursor in Command Mode When Not Typing

Instinctively hitting Escape after being in insert mode is the secret to avoid getting confused about whether the buffer is in command or insert mode.  Since the buffer is always left in command mode, no guessing is required.

Don’t Customize Your Setup

Some minor customizations may be acceptable, but as a newbie, focus on leveraging the built-in features of Vim and writing code.  Senior developers in my office have advised me that a customized setup is dangerous because it is time-consuming to set up and not accessible when you are on other machines.

Stick with the Basics for a While

Vim is a massive text editor with tons of powerful features, but you only need to scrape the service to enjoy using it immensely.  After using it full-time, you will stumble on shortcuts and run into Google solutions that are awesome.  A Vimmer that is comfortable with the basics can program productively and rejoice in the knowledge that an even more pleasurable programming experience awaits them when they get the chance to read a book on Vim.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s