Two Simple Steps Helped Me Learn Vim

I’ve wanted to learn Vim for a long time. But every time I tried to pick it up, I was overwhelmed with the endless possible keystrokes, perplexing modes, and odd navigation. I had been a Sublime Text 2 user for a long time (this is before 3). I ran through ‘vimtutor’ a couple of times, but even then, after I finished, I quickly forgot most of what I learned in the tutorial.

I knew that my lack of actually using it everyday was contributing to my slow progress. However, I was working for a consultancy and I needed to have a reasonable amount of efficiency in my daily programming, which I just didn’t have yet in Vim.

But, about six months ago, I decided to subscribe to Thoughtbot’s Learn program (now Upcase), and they had a series of videos all dedicated to learning Vim. The videos were very-well done and when I watched the videos, I saw how powerful Vim could be.

So, I decided to give it a shot again, but this time, I did two things differently, which dramatically helped my success.

#1 Use a Cheatsheet

This idea I think I got from Ben Orenstein (EDIT: Yep, found the article here and mentions the strategy below with the notecard) who mentioned using a cheatsheet. However, whenever I Googled “vim cheatsheet” I got images like this one…

vim cheatsheet

…which brought back nightmares of this…

periodic table

Those cheatsheets were overwhelming and lacking context, so they were of little help.

Another Strategy

I decided that every time I got stuck on how to do something in Vim, I would do a quick Google search to find out how to do it and then, keep track of those functions on a 3 x 5 notecard.

That’s right. An actual, physical, 3 x 5 notecard is my Vim cheatsheet. I keep it handy on my desk to reference it and add to it as I learn new things. Below is a photo of my current cheatsheet, because in reality, I’m believe I’m on iteration 3 of the cheatsheet. You could say I’m on version 0.3.

Adam DeLong Vim Cheatsheet

This was tremendously helpful, because early on, I often found myself trying to do the same things over and over in Vim and forgetting how they worked. Here’s a quick list of some of the things I would end up Googling…

Paste from the buffer in insert mode?
Comment out line in vim?
Indent a line in vim?
Copy two words in vim?

Of course, as I got better, I started to learn more “vim” efficient ways of doing things like the above. But writing down these steps helped me remember these individual steps.

#2 Complete Your Next Side Project in Vim

Like many curious developers, I often will have side projects that I work on during quiet nights and weekends. These projects are often done in technologies I’m already familiar with and don’t have the pressure of deadlines or hours to make which made them the perfect training ground to learn Vim.

So, after practicing and following along to the Vim videos, I decided to code my next project entirely in Vim. I will admit, I did not entirely adhere to this rule. I would sometimes get frustrated to the point where I would bust open ST2 in order to make a quick change that I had gotten stuck on. But for the most part, if I got stuck, I would Google, find the result and add it to my cheatsheet.

I noticed those times started to get less and less frequent. I started to feel really comfortable with the new Vim workflow. I decided to give it a try at work. I knew that at that point, if I ever got stuck, I could always Google and probably figure out the solution.

Sure enough, I started using Vim for work and before I knew it, it had been a week and I hadn’t opened ST2 once.

Additional Tips for Vim

While those steps were the most crucial to helping me learn Vim, here are a couple of additional tips.

  • Watch the talks on Vim from Ben Orenstein and Chris Hunt and learn from their dotfiles on github. Ben Orenstein and Chris Hunt
  • Use the ‘ctrlp’ plugin for file searching
  • ‘autoindent’ is your friend

Hey, I’m Adam. I’m guessing you just read this post from somewhere on the interwebs. Hope you enjoyed it. When I’m not writing these blog posts, I’m a freelance Elixir and Ruby developer and working on Calculate, a product which makes it easier for you to create software estimates for your projects. Feel free to leave a comment if you have any questions.

You can also follow me on the Twitters at: @DeLongShot