Vi For Smarties
- Start by typing vi followed by the file(s) you want
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.
- Hitting the Esc key always puts you in
It never takes you out of command
- 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
- 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
- Use h j k l to move left, down, up, and right,
- 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
Example: 3dw deletes three words starting from
the current cursor position.
- u (lowercase) means undo the last
- 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
All rights reserved.