How to Learn Vim

August 17, 2014

I’ve learned vim over the past year. Here’s some of the things I recommand to start learning vim.

Don’t learn vim unless you want to

Here’s the thing, I love vim a ton, and I can’t imagine using anything else for coding all day, but I have never recommended that someone switch to it. Why? You have to want to switch to it. I can’t force somebody; they would hate it. The best I can do is tell people why I enjoy it, and to let them see that it’s actually a prety good editor.

So unless you already have an interest in learning it, don’t let anyone force you to. You have to love learning vim, or you’ll never learn enough to actually get proficient at it.

Learn enough to get by

The first step is to just learn enough to barely scrape by. This might feel like torture at first. You’ll definitely slow way down before you start to get faster. So you’ll need to put in some time outside of work, so that your productivity at work isn’t killed.

When I first started using vim, I knew enough to open a file, move up, down, left, right, how to get in and out of insert mode, how to delete, and how to quit vim and that’s about it. Obviously, you have to keep learning more or it isn’t worth it, but you have to start somewhere.

Keep using it as much as possible

If you keep at it, certain commands will become muscle memory, which is good, because you can only remember so many commands in your head. If you use it as much as possible the more common commands will become second nature, so that you can focus on more and more commands.

Start the day with vim and stay in it as long as possible

Everyday, when you come into work and you’re fresh, instead of opening your usual editor, fire up vim instead. Just stay in vim as long as you want. And if you feel the urge, or really need to switch to another editor, no sweat, just switch to another editor for the rest of the day. As you get better, you’ll find yourself wanting to stay in vim longer and longer, and eventually you’ll be more productive in vim anyway.

Don’t disable the arrow keys, but try not to use them

There is a school of thought out there that will tell you that you need to disable the arrow keys in vim and use the hjkl keys to move around. This is actually the method that I used, but that’s just what I wanted to do.

Do what feels comfortable for you. If leaving the arrow keys enabled makes you more comfortable, then by all means, go for it. But do try to refrain from the arrow keys as much as possible.

Now that I’m pretty profficient, I’ve turned the arrow keys back on and I’ve enabled mouse scrolling and clicking. The reason for this is that I don’t want to completely alienate my coworkers when they come over to my computer and want to look at my code.

Keep notes

I think it’s extremely important to take notes during the learning process. I’m still make notes about little things I need to remember and things I want to research later to make my vim configuration better. Take notes about:

  • About what you don’t know
  • About what frustrates you
  • About what you need to remember
  • Any questions you have

Try to learn to use the vim docs

This is one thing that I’m not so good at myself. I tend to search online and ask questions on StackOverflow, but vim has great documentation (once you get used to it) and it’s all built into vim. You can just run the :h command to learn pretty much anything about vim.

Have fun

Try not to get frustrated. Learning vim should be fun, an adventure even.

Make vim pretty

The command line and vim by default don’t look very pretty compared to other text editors. And I think your editor should be beautiful, and you should enjoy using it and looking at it. So try out some different color schemes and make sure you get syntax highlighting. I recommend the Solarized color scheme. I would also recommend using iTerm 2 (for the mouse scrolling and clicking mentioned earlier) zsh, oh my zsh, tmux, and powerline.

Create your vim configuration slowly

You could go and completely copy someone else’s vim configuration, but it would be hard to know what everything does, and it would be hard to make it your own. Instead, just start with the basic vim, and slowly add things to your vimrc and to your plugins.

Version control your dotfiles

You’re going to make a lot of changes to your configuration over the years, and it’s really nice to have a version controlled history of all your dotfiles and configurations. And if you host them on github, you can share them with other people, and you’ll never lose them. It makes setting up a new computer much easier. Here are my dotfiles.

Find a vim friend

My best tip, and yet probably the hardest, is to find a friend that uses vim or is at least supportive of you using vim.

I went to a Startup Weekend in Ogden, and there was a guy on our team, Corey Woodcox that used vim full-time. For the first time I realized that it was doable, and I wouldn’t be out there completely on my own. It was cool to know that there are people that actually use and love using vim. He also answered several question for me on twitter.

It’s frustrating when your friends dis your choice of editors and you probably can’t convince them otherwise. On the other hand, a friend that uses vim can be very encouraging in the early stages of your learning.

Always keep learning

Good luck out there learning vim. It should be a fun ride!


Profile picture

Written by Adam Garrett-Harris, a podcaster and software engineer in Utah. You should follow him on Twitter