vi/vim Graphical Cheat Sheet & Tutorial

Last Thursday, while waiting for a friend at the airport, I was having a look at an ad for a Blackberry. I watched the beautiful two-chars-per-key keyboard and the tiny screen (magnified by the magic of marketing to something much taller than myself).

Then it struck me: a keyboard map for vi/vim would be really cool to see! And it shouldn’t be too much work! I certainly would have loved to have it when I was learning vi/vim, not that long ago.

The result is here: vi/vim Graphical Cheat Sheet & Tutorial. I sure think it’s one of the best ways out there to get started with vi/vim.

It’s currently on the front page of reddit & del.icio.us, so welcome to all visitors from there!

As for some context, I only started using vim a bit over a year ago. The reason? I was fed up with the arrow/home/end/pageup/… keys on my laptop being a pain to use. So, I took up learning vim. Turns out it was love at first sight. Read the details here. I now use it anywhere I can, desktop, laptop, whatever. Ok, not anything, I think Blackberries don’t support it, and I don’t own one to begin with, but a vi/vim interface to the Blackberry would probably be very cool.

After this, I had to add vi/vim emulation to the text editor I’m developing - I wouldn’t have been able to test it without that. And once done, I thought it might work as a commercial add-in for Visual Studio, released last July. And it is working a bit: it seems there are more souls claimed by vi/vim out there.

A friend helped me do all the work, and we used the open source application InkScape to actually draw it.

It seems many people are visiting the cheat sheet & tutorial page - hopefully it will help them learn vi/vim, and it will also provide some nice exposure to ViEmu.

Although I don’t practice much proselitism in this aspect, let me state that one should look at vi/vim’s unique input model not as a relic from old times, but as a different UI model. Optimized for reducing keystrokes & maximizing editing power, both at the expense of the initial learning curve & operating simplicity. It doesn’t matter Bill Joy invented it in the 70s, if he hadn’t thought it up back then, someone would have to invent it today. Admittedly not for mainstream consumption, but I’d buy it as happily.

23 Responses to “vi/vim Graphical Cheat Sheet & Tutorial”

  1. Marius Gedminas Says:

    Lovely keymap!

    Some comments:

    * The examples of words and WORDS are the same, you could illustrate the difference better with an example like

    quux(foo, bar, baz);

    There are three WORDS here

    [quux(foo,] [bar,] [baz);]

    and eight words:

    [quux] [(] [foo] [,] [bar] [,] [baz] [);]

    * vi-vim-tutorial-3.gif says “text deleted with w, c, p… is also copied”. But you cannot delete text with ‘p’ in vi.

  2. J Says:

    Marius,

    Thanks a lot. Your sample is much better. And, yes, that is a typo on lesson 3 - it should be ‘d’, ‘c’, ‘x’. I will fix both and upload a 1.1 version later today.

  3. Robert Fisher Says:

    Love the vi cheatsheet! I just wish you had a dvorak version. (^_^)

    I also like the graphical tutorial. I think that would be a great way to learn vi. I even learned a couple of things from it. (0 & H)

  4. J Says:

    Hey Robert,

    I’m holding off from trying out a Dvorak layout until the business gets off the ground. If I start preparing products for Dvorak vi users, I think it will never will :) But I’ll definitely try it out some time.

    Someone over at reddit has writtten a comment that he was preparing a dvorak version, so be sure to check there!

  5. Tiberiu Micu Says:

    Lesson 6: G jumps to the beginning of the file
    I think it must be: G jumps to the end of the file (or to last line)

  6. Tim Says:

    I have to second the request for a dvorak version!
    But this will go a long way to help just the same.
    Thanks!

  7. J Says:

    Tiberiu, you’re right. I’ll have to fix the typos. But: it’ll have to be tomorrow, as my DSL line has broken a while ago and I’m at a friend’s!!

    Tim, there is already a dvorak version done by some helpful soul. You can find it linked from the comments over at reddit.com.

    I’ll talk to the author and host it at viemu.com if he agrees to (with proper credit, of course).

    Thanks for the nice comments!

  8. S Says:

    2 things you may want to add in a further lesson

    “:sp” - Splits your window in 2 panels equally

    “Ctrl-w” - Toggle between the pannels inside 1 instance of vim

  9. Douglas Clifton Says:

    gg — first line in file
    G — last line

    Really nicely done. Vim is so powerful, I sometimes need reminding that there are always faster/easier ways of doing things. I may have to print out your cheatsheet and stick it on the wall in front of my desk. Thanks!

  10. Senthil Says:

    good work. should be helpful many of the beginers.
    Just a note to to check or start with :help user-manual would be more vimish.
    And if you have not stumbled across this yet, then:
    http://www.open-sorcerer.de/t-ref/
    is a cool one also.

    btw, does any one have an idea of using vim emulation with bloodshed.net’s DevCpp?

    Thanks!
    Senthil

  11. Wes Says:

    Hi, I like the keymap and would like to print the SVG so it prints nicely but I don’t have the same Font you used so the text is all a little out of alignment. A PDF version would solve this and also wouldn’t require people to install Inkscape.

  12. Pete Says:

    This is great. I am a huge vi user but my boss teases me because he is an emacs guy. Maybe you could make an emacs version to help demystify those emacs control sequences for vi users. It would be nice to be proficient in both.

    Thanks,
    Pete.

  13. J Says:

    Thanks everyone for the comments.

    S: it was very tough to leave stuff out, but I had to make a call! There are a ton of things that are not there. Also, one of the goals was to make vi/vim less scary for users, and too many commands would detract from that.

    Senthill: Thanks for the pointer, I’ll consider the :help user-manual point.

    Wes: I’ll try to prepare a PDF rendering.

    Pete: tell your boss that vi is the same as emacs, but with the control key pressed by default, you just need to enter ‘i’ to release it and Esc to press it back.

  14. Gaby Says:

    Thank you for the beautifully laid out pictures. Many of my co-workers want copies now. Just one question: could you please provide an SVG of the complete cheat-sheat as well as the seperate lessons? The Gif won’t print nicely while Inkscape gets it right.

    Thanks!
    Gaby

  15. J Says:

    Gaby, you’re welcome. The SVG version of the complete cheat-sheet is linked there from the page itself! It’s available as a zipped SVG file, linked from the second paragraph.

  16. Daniel Einspanjer Says:

    Thanks for the great cheat sheet! I’m a Vim user since ‘99, and even for me this is handy because it reminds me of some of the motions and operators that I forget about (like ‘,’ and ‘;’). I printed out a dozen copies and passed them around the office to the people here who consider it a chore to have to run vi/vim on one of our unix boxes and don’t yet understand the power and efficency of it. :)

    One comment I have for improvement.. the typical mnemonic for ‘f’ and ‘F’ is ‘f’ind a character and ‘f’ind a character backwards. That will make your text for the ‘F’ key a little less stressed. :)

  17. J Says:

    Daniel, thanks for the compliments & for the hint on ‘f’. I’ll consider whether to add it, my personal mnemonic has been f’orward :), but it will sure much more sense your way.

    I’ll be preparing a “1.1″ version, most probably during the weekend, with all the typos above fixed.

    A nice guy has prepared a dvorak version (you can find it at the reddit.com comments, http://reddit.com/info?id=3ncs), which I can use as a reference, so I might prepare a dvorak version myself as well. I’d be glad to host his version and credit him for it, but I can’t find a way to get in touch with him…

  18. J Says:

    I have just posted an updated version (1.1) with all of the fixes & some of the suggestions above. Thanks everyone for the feedback!

  19. toni Says:

    great work! thanks a lot!

  20. Offtopic Question Says:

    I too have stared at the blackberry keyboard and wondered one thing.
    If I get one and an ssh client, where is the “esc” key to properly use vi?

  21. J Says:

    Hmm… Ctrl-[? Alt-27? Hidden somewhere under the battery location?

  22. JR Says:

    I run Idokorro Mobile SSH on my Blackberry. For the escape key, I need to click the wheel, select ‘Special Keys’, then Q. Not very quick but good for small tasks.

  23. gratis Says:

    Excellent browsing have the to

Leave a Reply