How do I use the vi text editor?
The vi text editor has three modes: command mode, input mode, and ex mode.
When starting, vi begins in command mode. If you are ever unsure which mode
you're in, press
Esc to return to command mode. In command
mode, you can move around with the arrow keys, or by using the vi
movement keys, as follows:
Several vi commands are listed in the table below:
||Go back one page|
||Go forward one page|
Delete the character the cursor is on
Delete the character before the cursor
||Delete the current line|
Delete everything from the cursor to the end of the line
Undelete a line you just deleted
Undo all changes to the current line
Save your file and exit the vi editor
8and then type
The input mode lets you insert or append text. To insert text before
the cursor's current position, in command mode, press
i. Similarly, to append after the cursor,
you can type
a. Remember that you can't move
around with the cursor keys in this mode. When you're done entering
Esc to go back to command mode.
The ex mode is an extension of command mode. To get into it, press
Esc and then
: (the colon). The
cursor will go to the bottom of the screen at a colon prompt. Write
your file by entering
:w and quit by entering
:q. You can combine these to save and exit by
:wq. However, if you're finished
with your file, it's generally more convenient to type
Shift-z-z from command mode.
For a more thorough list of vi command keys, see A quick reference list of vi editor commands.
At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?
This is document adxz in the Knowledge Base.
Last modified on 2015-05-13 00:00:00.
- Fill out this form to submit your issue to the UITS Support Center.
- Please note that you must be affiliated with Indiana University to receive support.
- All fields are required.