Vi For Smarties
Lesson One
Basic Concepts
- Start by typing vi followed by the file(s) you want
to edit.
Example: vi one.txt two.txt etc.txt
- There are two modes: command mode and insert mode. You will begin
in command mode. (Unless you have a config file which changes this.
Rare.)
- Hitting the Esc key always puts you in
command mode.
It never takes you out of command
mode.
- Commands only work in command mode. Get used to hitting
Esc a lot.
- Esc is your friend. If you begin to issue a command and then
change your mind, always hit Esc a few times to
cancel.
- Remember: ALL COMMANDS ARE CASE-SENSITIVE!!!
Basic Editing Commands
- Hitting i or a from command mode
puts you in insert mode. i starts
inserting text before the cursor.
a starts appending text after the
cursor.
- Use h j k l to move left, down, up, and right,
respectively.
- Use w e b to move forward one word,
forward to the next end of a word, and
back one word, respectively.
- Use x to delete one character, dw to
delete one word, or dd to delete one whole line.
- Use a number before a command to repeat the command that many
times.
Example: 3dw deletes three words starting from
the current cursor position.
- u (lowercase) means undo the last
change.
- ZZ (uppercase) saves any changes and quits.
- :q! abandons any changes and quits.
Until you have mastered everything on this page, you are
not ready for Lesson Two.
Copyright © 2001
jerry_y_wang@yahoo.com.
All rights reserved.