How to Accidentally Learn Vim

I have a confession to make: I wasn’t always a Vim user. There was a time when I used such editors as Aptana Studio 3 and Sublime Text 2.

I was fond of these editors, enjoying such benefits as being able to use a mouse to quickly select text, performing the same edit in multiple places, and having an inbuilt terminal.

The Git Commits

Despite my editor of choice having a graphical interface, I found that making Git commits was much easier and faster if I used Vim, since that whole process stayed in the terminal. I was familiar enough with Vim’s modes and :wq that it was faster to do that than to try and use one of Sublime’s Git wrapping solutions, and the terminal was where I was running tests anyhow, so it wasn’t too far out of my way.

Over time, a strange thing happened. I would start my day in Sublime, merrily hacking away at my sometime Rails project. The feature complete, I would commit the changes. Then I would keep working, this time in Vim.

It wasn’t really a conscious decision, but I began spending more and more time in Vim. I set up Vintage mode in Sublime to make things a little less jarring when I switched contexts, but I found that while Vintage perfectly replicated a subset of Vim’s power, it was no substitute for the real thing.

When I came to thoughtbot I ended up moving to Vim full time. Reasons for this included the pressure to adopt Vim so that I could more effectively pair and my own urge to take the plunge.

The Power

Jafar genie conjuring solar systems in Aladdin

Yes! Yes! The power! The absolute power!

This is when I started to realize how much I’d been missing. Even when I’d used Vim before, the best I could do was to :s to search and replace or Shift-V to select full lines. Using it full time, I was able to really get into its power.

Of major benefit was to pair with someone else using Vim. I would often see something magical happen in the editor and stop my pair, asking them to back up and show me how they had done it. Through this, I was inducted into the friendly society of those pairing commands with motions (d$, yiw, v^), and introduced to plugins such as vim-surround.

As my ability to edit effectively increased, my addiction became ingrained. Now, editing text in places where I need to use a mouse or arrow keys to move the cursor or make selections is a chore: Inefficient and tedious.

Getting Started with Vim

I’d love for you to join me in enjoying Vim’s power. If you are a Sublime user, I recommend turning on Vintage mode. When you become comfortable with that, it may be time to move on to the real thing. For further advice, check out thoughtbot’s Vim trail or check out the Art of Vim series of screencasts.

Happy editing!