September 4, 2024

A first session with Vim

On many systems, you won't need to install it. You will be able to type "vi" or "vim" at the command line to start it up. On my linux system, either will work, but by default "vi" runs it in a dumbed down historical compatibility mode. There is also "gvim" on some systems, which I never use, but which offers vim in its own graphical window. I always launch some kind of terminal window, then run vim in that window.

Getting out of vim

This is an important first thing to know with any program. The short answer here is to use :q. This exits without trying to save anything. My normal way to exit is to use ZZ which saves changes and exits. If you want to save and abandon changes you must use :q! where the "bang" means that you really mean it.

Run the tutor

On a linux system type "vimtutor" on the command line and away you go. You will get a nice lesson that will get you started with vim and should take you less than an hour. If your system does not have this, start vim and then type:help tutor. This should give instructions on how to start the tutor in difficult and abnormal cases.

The hjkl keys

You may have habits formed of using the "arrow" keys on your keyboard. These do work with vim, but there is a better way. Try using the hjkl keys instead. There are two reasons why this is better. One is that they lie right below the fingers of your right hand when it is in the normal position for touch typing. The other is that you may someday find yourself on some keyboard without arrow keys! Once you learn them, muscle memory takes over and you think "move up" and you do move up without even knowing what your fingers do.

Touch typing

If you do not touch type, learn how. Set aside a week and just do it. You will of course slow down drastically at first and be annoyed, but once you practice and form muscle memory, you will be much much faster. This is one version of a big life lesson -- one that I seem to keep learning over and over. Don't be in a hurry, pay your dues, and you will get there faster.


Have any comments? Questions? Drop me a line!

Tom's vim pages / tom@mmto.org