Using the vi editor

For any linux/unix- newbies like me, a quick tutorial on the vi editor might be needed. Here are some short instructions on using it, taken from the "Using Amiga UNIX" manual, page 99-119.

Using the vi editor

This chapter provides a brief overview of basic vi (visual text editor) editing commands. To find out more about vi's advanced commands, read the vi man pages.

To start the vi editor, type vi and the name of your flie. lf you don't include a filename, vi starts editing in an unnamed buffer; you can't save the file until you name it.

The vi editor has a unique editing feature; keys perform differently depending upon what "mode" you're in. vi works in three modes: basic command mode (keys perform editing tasks), file command mode (save and quit), and insert mode (keys insert text characters).

Use the ESC key to end insert mode and return to command mode. When you first enter vi, you're in command mode. You can press an insert command key (such as i) to begin typing text. When you wan to edit your work (to change, add, or delete a word), press ESC to end insert mode and return to command mode. While you're in command mode, the keys on your keyboard issue commands; you can't enter text until you press a insert command key (a, A, i, I, o, O).

You can use the arrow keys to move the cursor around while staying in insert mode. You don't need to press ESC before using the arrow keys; they're not considered command keys, but rather special function keys within insert mode.

If you forget which mode you're in, just press ESC to return to command mode, then start again.

The vi editor doesn't automatically wrap text, so you must press RETURN when you reach the end of a line on your screen.

Special keys
ESC cancel insert mode
CTRL-L redraw screen
CTRL-D scroll down
CTRL-U scroll up

Quit and save
:q! quit without saving
:wq save and quit a file
:w save your work
:r file read another file into your current file

Move in a file
w to next word
0 back to beginning of line
$ to end of line
G to the lasLline
:n move to line numher n

Insert and append
i insert text
a add text
o add blank line

Delete text
X delete character
dw delete word
dd delete line
ndd delete n lines

Undo and repeat
u undo last change
U undo changes to line
. (dot) repeat last change

Move and copy
dd cut
yy yank (copy)
p paste below

Change text
cw change word
cc erase a line and insert
c change to end of line

Search
/ search
n repeat search
N reverse search
Contributors to this page: MindWalker .
Page last modified on Friday 06 of December, 2013 14:00:30 EST by MindWalker. (Version 1)