40Chapter2 • Working With Editors
In addition to simply entering text into the buffer, vim can change text already in the docu-
ment. Table 2-16 lists the commands for changing text and their function.
Also of note are the deletion commands. They are entered from Normal mode and may be
used to delete a character, a word or a line at a time. These commands are listed in Table 2-17.
Automatic Indentation
There are several indenting options available with VIM. They are
autoindent
,
smartindent
and
cindent
. The first,
autoindent
, simply copies the indentention from
the previous line and uses that as the default for all new lines entered into the buffer.
Smartin-
dent
and
cindent
are similar, but
cindent
is stricter in the way that it handles the format-
ting and may not be suitable for programming languages other than C.
Table2-15 Entering Insert mode
ActionCommand
i aBegin inserting characters at the cursor, after the cursor
I ABegin inserting characters at the beginning, end of the line
o OOpen a new line after, before the current line
Table2-16 Commands to change text
ActionCommand
cwChange from the current cursor position to the end of the word
ccChange the current line
rReplace the letter at the cursor
R
Replace from cursor on
Table2-17 Deletion commands
ActionCommand
x XDelete the character at, before the cursor
dwDelete from the cursor to the end of the current word
ddDelete the current line
DDelete from cursor to end of the current line