Hashrocket.com / blog

How to Switch from TextMate to Vim

posted on and written by in

Image 100x100 vic ramon

Switching to Vim from an editor like TextMate or SublimeText can be intimidating. You might find yourself dreading your time editing text, but I’m here to tell you the effort is worthwhile. When starting at Hashrocket, I found myself immersed in a Vim culture. I decided to make the switch after seeing a hint of what’s possible. It was difficult, but I’ve become quite proficient, and want to share my insights with you!

What surprised me the most about Vim is that it is genuinely fun. Learning new commands is like learning magical incantations. Short keystrokes can do powerful things. This makes improving your knowledge of Vim fun.

Myth Busted: The Vim Learning Curve is Not That Steep

You often hear that Vim is a beast to master. While that may be true, I think you can become productive in a short time. In fact, I think you become more productive than you were in your old editor in just a couple of weeks with some work and focus.

I think the 80/20 rule applies to Vim: you can be very productive by just knowing 20% of all the things that Vim does. That’s not to say that you should be ignorant of the other 80%, just that it will take time to learn it all. You don’t need to know everything to make Vim work for you.

How to Get Started

Here are some things you can do to become productive in just a few days:

Open up a terminal and type vimtutor. This opens up Vim’s built in tutorial. It does a great job covering all the basics. Do the whole thing. You’ll want to come back to it in a few days and do it over again to help cement all the commands in your memory.

Check out VimGenius. It’s a flashcard-style learning application for Vim that I created to go along with vimtutor.

Print out a copy of this Vim commands cheat sheet: here. Read over the whole thing and keep it handy.

Take notes and circle commands that you want to remember or that you particularly like. Use post-its, or flashcards, pen/paper, chalkboard, well…anything. Just do it by hand!

Next, I would recommend doing some kind of task requires a lot of movement. I did the Ruby Koans, which worked extremely well for me. If you try and work on an actual project at first you might feel flustered, so doing something practice oriented like the koans is a good idea just to get your handles down. If you’re not a Rubyist then try and find some other kind of task, e.g. Python Koans for python developers.

There are also a few games that can help you learn Vim: Vim Adventures and Vim Snake are great at helping you master the hjkl movements. These movements require some muscle memory to get right.

This image does a great job at showing the direction and relative distance each command will take you. You could set it as your desktop background if you were so inclined, or just print it out and keep it handy.

Chris Hunt gave an excellent talk called “Impressive Productivity with Vim and Tmux” at Hashrocket’s Ancient City Ruby Conference, which you can watch here: http://www.youtube.com/watch?v=9jzWDr24UHQ

Once you’ve done all of this and feel comfortable getting around, I recommend that you start actually using Vim for your work. It will be slightly painful at first, but you’ll get the hang of it more quickly than you expect.

Posted in Development and tagged with Vim