How to start learning vi/vim

So, you'd like to give a chance to vi/vim and you want to start learning it. It will take time to learn, but I can tell you that, if you do learn it, you will very probably become hooked to it.

The first thing, dowload vim. It's available for basically any platform, and it's the most popular vi clone around - it brings in so many useful features that vim users do not want to go back to vim. gvim is the GUI-integrated vim that has a toolbar, menus, and overall GUI integration.

The second thing is that you get used to the fact that, in vi/vim, keys do not type directly - they are usually commands, and, in order to type, you have to press 'i' get into "insert" mode, where you will remain typing until you press <ESC>.

The third thing would be that you learn the basic commands:

  • In order to exit, press <ESC>:q<RETURN>. If you are within a modified file, it won't exit so as not to lose your changes. In this case, you need to use <ESC>:q!<RETURN>. The <ESC> key gets you out from insert mode if you were there (it does nothing but beep if you are already in command mode - properly called "normal" mode)
  • 'h', 'j', 'k', 'l' move you around: h-l are left and right, k is up, and j is down. It's easy to remember if you think that the 'j' character has a tail downwards and 'k' extends upwards. They seem a bit weird given that they're just one key left of the home position for the right hand, but it's quite natural, as you will usually use 'h' and 'l' very little, and you'll use 'j'/'k' more often.
  • 'i' gets into insert mode just before the current position where the cursor is, and you can insert text at will until you press <ESC>. vim even allows using the arrow and navigation keys within insert mode. If you want to insert after the current position, you need to press 'a' instead of 'i'. This is useful to append at end-of-line, although 'A' goes directly to insert mode at end of line, no matter where the cursor is on the line.

Finally, I think you could do much worse than heading over to Efficient editing with vim by Jonathan McPherson. It is a very to-the-point short document detailing the commands that will let you edit with vi-efficiency, and will be a nice guide on what to learn. You have ample online documentation in vim itself (type :h whatever_command_or_key), and you can also find many vi/vim tutorials on the net.

Good luck!