A Brief Introduction to Vim

After my initial hazing, I have decided I’m in love with Vim.

It turns out that learning Vim is a lot like learning to type properly. At first, it really slows you down because you have to teach your fingers what to do. Later on, after your brain gets the heck out of the way and lets your fingers take over, the investment really pays off.

I’m not yet to the real payoff stage, but I can see it on the horizon.

Here are a few tips for anyone wanting to learn Vim:

Why should I learn Vim?

Because once your fingers learn the keys, you will be able to move through your programs much more quickly, use shortcut commands for every action you can possibly think of, and understand what’s going on if you pair program with someone who uses Vim.

When should I learn it?

Whenever you can afford to temporarily cut your productivity in half while your fingers learn the movements. In other words, NOT when you are in the middle of learning a new coding language or have a major work or school deadline coming up.

How should I start learning?

1. Try out VimAdventures for a fun adventure-game-style tutorial. I only did the 3 free levels, since I didn’t like the idea of a 6-month subscription. (I go through that kind of thing in a week, so I’d want either a 1-month subscription or a permanent download that I could come back to for review.)

Vim Adventures

Vim Adventures

2. Download Vim and then open the Vim Tutorial. Apparently that’s as easy as typing


on the command line. If you read my last post about Vim, you’ll know that I spent a good long time trying to figure out how to get into VimTutor from inside Vim. Do not try that at home.

3. Get more practice by downloading these excellent Vim Exercises. If you have Git installed, you can run the following command in the terminal:

git clone https://github.com/skilldrick/vim-exercises.git

(If you don’t have Git installed, you would probably be better off investing your time learning Git.)

4. Start coding in Vim. Do some Project Euler problems to some other code exercises using Vim.

What else should I know about Vim?

Vim has several different modes that it helps to be familiar with:

Name Description help page
normal For navigation and manipulation of text. This is the mode that vim will usually start in, which you can usually get back to with ESC. :help Normal-mode
insert For inserting new text. The main difference from vi is that many important “normal” commands are also available in insert mode – provided you have a keyboard with enough meta keys (such as Ctrl, Alt, Windows-key, etc.). :help Insert-mode
visual For navigation and manipulation of text selections, this mode allows you to perform most normal commands, and a few extra commands, on selected text. :help visual-mode
select Similar to visual but with a more MS-Window like behavior. :help select-mode
command-line For entering editor commands – like the help command in the 3rd column. :help Command-line-mode
Ex-mode Similar to the command-line mode but optimized for batch processing. :help Ex-mode

The 2 modes you will probably use most at the beginning are Normal Mode and Insert Mode.

Normal mode is where the keyboard keys are interpreted as shortcuts. For example, the letter “j” would move the cursor down. From here you can move into insert mode with several different key commands, such as typing “i” or “a”. The only difference is where the text is inserted. ‘i” will insert text starting at the current position of the cursor. “a” will insert text starting at the position after the cursor.

Insert mode is where whatever you type is interpreted as text. The letter “j” would just put a “j” wherever your cursor is. To get back to Normal mode, you press Esc.

And that’s it. That’s pretty much everything you need to know to get started.

I got some excellent tips from readers on my last Vim post, and they helped me out a lot.

If anyone else has tips or questions, please leave a comment. Thanks!



One thought on “A Brief Introduction to Vim

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s