Thursday, November 11, 2010

Using Spaced Repetition Software to Master Vim

I've been a vim user for about 20 years. During that time I've used IDEs and other text editors, but I've never found one to fit my needs better than vim does, and I always end up finding my way back to vim. As a developer's editor, it's really making inroads in the Ruby community, which I love because it means there are lots of great vim plugins being developed and improved right now, and my experience with vim is getting better all the time.

However, I've also found that I'm often aware that a particular command exists, but I don't remember it long enough to be able to use it when I need it. It's a pain to have to look up a command when what I really want to do is to write code. So, I've gotten to a set of core commands that I know, and when I get that particular itch, I take the time to look up a particular command, use it, and usually forget it sometime in the next 24-48 hours. It turns out that when you learn something, if you fail to reinforce or exercise that knowledge you will inevitably forget it. When was the last time you tried to remember a list of capitol cities that you memorized in grade school? You use it, or you lose it.

Spaced Repetition Software

Spaced Repetition Software, SRS for short, is software that keeps track of how long it takes for you to forget something, whether it's vocabulary in a foreign language, state capitols, or other facts, and refreshes your memory at just the right time to keep you from forgetting. I first learned of SRS through Piotr Wozniak's SuperMemo (which is about incremental reading as much as it is about SRS), but there are many flashcard-only systems out there that will drill you on things you want to remember.

I asked on Twitter if anyone knew about flashcards for vim and didn't get much response. I think the very notion of SRS is new to people (it was new to me), so there's not much activity in this area. Still, I started to think that this could be an excellent solution to my problem of learning new vim commands: If I could simply memorize a bunch of commands, those commands would be ready at my beck and call when I was writing code. It was time for an experiment.

Enter Anki

I checked out a few different SRS systems before settling on Anki , which is free and open source, and available on Mac, Windows, Linux, and Android. There is also an iPhone version that will set you back $25, and an open source program called Mnemosyne that does SRS.

Vim Commands Stack

So, the Vim Commands flashcard stack was born. I started adding commands that I wanted to learn, guided by quick reference cards, vim's own excellent help system, and my own vague notion that "there's a command for that, if only I could remember what it is…"

I started spending just a few minutes a day memorizing and reviewing commands, and collecting more commands, until I had a pretty decent collection. The experiment started bearing fruit almost immediately. I was able to remember some of the more obscure cursor movements, search commands, advanced undo commands, and so on. Before long I was giving my co-workers tips on advanced commands that would help them out.

Today the stack has 241 commands, many of which I knew existed but never could remember when it was time to use them. I regularly pause to remember a command and it comes to me quickly. Some of these commands have already become part of my muscle memory, and it feels like many more are on their way.

Github Project

I've exported the stack from Anki and am keeping it in a text format that is easy to edit and re-import to Anki. I've reordered the facts in the deck to start with Basic commands, progress through Beginner commands, to Intermediate and Advanced commands. The Github project is called vim_flashcards and the all_cards.txt file is suitable for import directly into Anki.

Currently the cards are all stored in a flat file, but I'm thinking about creating a Ruby gem for managing SRS flashcard stacks and exporting them to multiple systems. Please contact me if you are interested in helping out with this effort.

Getting Started With Anki

You can begin by downloading Anki and installing it. Once it starts up, click on the "Download" button and search for "Vim Commands". Alternatively, clone the github repository and import the cards into Anki from the all_cards.txt file.

When you open the deck, be sure to tune the goals to your liking. For beginners, I would recommend no more than 5 new commands per day; expert users might want to stick with 20 or even set the value higher. Remember, if you're trying too hard, you might fatigue out.


My vim flashcard experiment is still in its early stages. I'm still adding new commands on a regular basis, and still trying to organize the stack so that it is presented in an order of increasing difficulty, with the easiest and most useful commands at the beginning, and the harder and more esoteric commands at the end. It will be interesting to see how relevant the stack is to me in the long term: will it be necessary to keep commands in mind, or will I use all of them regularly enough that refreshing them with Anki becomes redundant?

I invite you to participate in the experiment and provide feedback. If you use the vim deck, let me know if you find it helpful, whether you're brand new to vim or an old hand. Actually, if you're brand new to vim, I recommend that you first go through vimtutor (type "vimtutor" at the command line and start reading) before trying out the Anki deck.

If you use a different text editor, like emacs or TextMate, you might want to create your own flashcard stack to help you remember all the commands for your editor.

Happy editing!


  1. Thank you for your time and effort in putting this together.
    Just stumbled on this blog through google -> flashcarddb, I am sure this will help me!

  2. I hope you find it helpful! I know a good number of people have downloaded the flashcard stack through Anki, but I haven't really gotten much feedback.

    It continues to be helpful for me!

  3. This is great. Thanks for doing it. The only thing that I think would significantly improve it is to write a plugin that teaches the deck to recognize typed commands. Currently you can set the deck to allow user input, and then it will compare with the answer. This works for simple commands, like move left (h), but fails on commands that involve CNTRL, RETURN, or ESC (or equivalently CNTRL-[, which I use). I think this would allow the user to develop muscle memory much faster.

  4. This is really cool. I consider myself an advanced user of vim, but I notice that I tend to get lost in doing things my own little way and there are many commands I still need to learn.

    I tried this out using Anki and already learned two more useful commands. I will continue to do this daily and let you know how it goes.

  5. hello, I will read everything about this blog.

  6. Thanks very much for this, Alf. I've been using your card deck for 2 days now and wouldn't have tried to learn VIM without it.

  7. Very helpful, thank you! I went searching for physical flash cards but this is perhaps an even nicer solution. I only know the very basics of Vim now, maybe two dozen commands, but I'm sure this will ratchet up that number quite quickly.