38Chapter2 • Working With Editors
2.4.1VIM Concepts
There are two basic modes within VIM that determine VIM’s behavior. These two modes
are Normal and Insert. In Normal mode, the editor expects the user to enter commands that per-
form a number of functions. In Insert mode, the editor inserts typed characters into the current
document.
The editor starts in Normal mode. To return to that mode from Insert mode, press the
ESC
key.
2.4.2Basic Editing
As previously noted, VIM is based on the vi editor and anyone familiar with vi’s editing
keys will immediately be at home with VIM.
VIM uses two methods of entering commands into the application. Simple commands
such as those used for navigation and entering Insert mode are one- or two-letter commands that
are case sensitive and are not echoed to the screen as they are typed. More complex commands
such as those used to perform searches and utilize the tags created by the
ctags
program are
entered and echoed into the last line of the application screen. A colon, slash or question mark
character is used to activate the last line mode and enter the command. The character used will
depend upon which command is being issued.
Most simple commands can be preceded by a number. When this occurs, the command
entered is treated as if it had been entered that many times. For example, the command to delete
a line in a buffer is
dd
. If this command preceded by the number 15, as in 1
5dd
, the next 15
lines in the buffer will be deleted.
To exit VIM, type
:q
if the text has not been changed,
:q!
to abandon all changes made
to the file, or
:wq!
to save all changes and exit.
For help on any function, type
:help
where is the name of the func-
tion. Typing
:help tutor
will bring up information about VIMs built in tutor file. This file will walk you through the
basics of using VIM.
Navigation
If the terminal that is being used is set up correctly, the arrow keys on the keyboard will
often work for simple navigation commands that move the cursor around the screen. If the termi-
nal type is not properly configured, alternate keys may be used to navigate through the text.
The “h”, “j”, “k”, and “l” keys can be used in place of the left, down, up and right arrow
keys respectively. Additionally, the cursor may be moved one word, sentence or paragraph at a
time by using the keys listed in Table 2-13.
Next Page >>
<< Previous Page
Back to the Table of Contents