|
|
You can correct mistakes in vi by using the x key to delete the character under the cursor.
You need to be in command mode (press <Esc>) to use x to delete -- otherwise, you just end up with a lot of x's. After you have deleted the unwanted text, insert the correct text by pressing i. Text is inserted to the left of the cursor.
Try editing the first line of weekrep:
:
to get the
:
prompt at the bottom of the screen.
:
prompt to save the file
and exit vi.
Q: I am finding it hard to tell when I am in insert mode and when I am in command mode -- is there any way to make this easier?
A:
If you are in vi, you can press <Esc> to go to
command mode, type :, and then type set showmode to set
the showmode option.
The showmode option prints the mode you are in at the bottom of your
screen whenever you are in input (insert) mode.
The mode it prints will
be APPEND
, CHANGE
, INSERT
, OPEN
,
or REPLACE
,
depending on your current action.
If you always want to use the showmode option, create a file in your home directory called .exrc that contains the following line:
set showmodevi looks for the .exrc file each time it starts, so this is where you should put frequently used vi options. For more information about vi options, see the section on vi in ``Editing files''.
Q:
Suppose I type a colon and then change my mind and decide I do not want to use
the :
prompt?
A:
Press <Del> to cancel the command and return to editing the file.
Your terminal may beep or flash at you; ignore it.
You can also type <Esc> if you have not typed a valid command, but,
if you have typed a command and you press <Esc>, vi
performs the command you typed.
Q: Why does my terminal keep beeping (or flashing) at me?
A: vi sends a beep to your terminal (some terminals use a flash) in a number of instances. Two common times vi beeps at you are when you press <Esc> when you are already in command mode, and when you try to move beyond the last text on a line.
When you first start using vi, your terminal beeps a lot.
You can safely ignore this.