Learning the way the help system system works in any application you use is always a good idea. In vim, it isn't just a good idea, it's essential. When I first started using vim I put it off for the longest time. I wish I wouldn't have done that!
Thanks to vim's hard working developers vim has a very extensive built-in help system. As part of their work they developed a tutor which will walk you through the basics.
To start the tutor simply type this command at the console:
bash$ vimtutor |
Vim should start and look something like this:
=============================================================================== = W e l c o m e t o t h e V I M T u t o r - Version 1.4 = =============================================================================== Vim is a very powerful editor that has many commands, too many to explain in a tutor such as this. This tutor is designed to describe enough of the commands that you will be able to easily use Vim as an all-purpose editor. The approximate time required to complete the tutor is 25-30 minutes, depending upon how much time is spent with experimentation. The commands in the lessons will modify the text. Make a copy of this file to practice on (if you started "vimtutor" this is already a copy). It is important to remember that this tutor is set up to teach by use. That means that you need to execute the commands to learn them properly. If you only read the text, you will forget the commands! Now, make sure that your Shift-Lock key is NOT depressed and press the j key enough times to move the cursor so that Lesson 1.1 completely fills the screen. |
Simply follow along with the tutor. Below is the outline of what the tutor covers in case you are already familiar with vim. I recommend you continue using the tutor until you can complete it "out of sequence." In other words, you ought to be able to jump around throughout the tutor, doing sections at random, before continuing with the rest of this document.
Moving the cursor
Entering and exiting vim
Text editing-deletion
Text editing-insertion
Deletion commands
More deletion commands
On commands and objects
Exceptions to command-object
The undo command
The put command
the replace command
The change command
More changes using "c"
Location and file status
The search command
Matching parentheses search
A way to change errors
How to execute an external command
More on writing files
A selective write command
Retrieving and merging files
The open command
The append command
Another version of replace
Set option
Online help commands
Vim has an extensive help system. The most basic command is:
:help |
This command will take you to vim's help text. Throughout the help files you will see tags like this: |bars|. By positioning your cursor over these tags and hitting CTRL-] you can jump directly to the subject. To get back to your original position simply type CTRL-t.
You can quit the help window by typing :q. |
A variation of the above command is this:
:help subject |
Where subject is the information you are looking for. One thing to note about the above command is that it takes you to the subject reference. What this means is that this type of help is aimed at users who are already familiar with vim's help syntax. The vimtutor command in the Tutor me! section covers this in Lesson 2 of the vimtutor. You did do the vimtutor didn't you?
You can also access vim's help by pressing the F1 function key. |
Vim's help also contains some quick reference links which you can locate by typing:
:help quickref |
If you're looking for less terse explanations a good place to start is with the vim introduction. In addition to the introduction you can find more detailed help with this command:
:help doc-file-list |