Amiga Unix Wiki

Because AmigaOS just isn't obscure enough today!

User Tools

Site Tools


vi-editor

This is an old revision of the document!


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.

Table 1: Special keys
ESC cancel insert mode
CTRL-L redraw screen
CTRL-Dscroll down
CTRL-Uscroll up
Table 2: Quit and save
:q!quit without saving
:wqsave and quit a file
:wsave your work
:rfile read another file into your current file
Table 3: Move in a file
wto next word
0back to beginning of line
$to end of line
Gto the lastline
:nmove to line number n
Table 4: Insert and append
iinsert text
aadd text
oadd blank line
Table 5: Delete text
Xdelete character
dwdelete word
dddelete lline
ndddelete n lines
Table 6: Undo and repeat
uundo last change
Uundo changes to line
.(dot)repeat last change
Table 7: Move and copy
ddcut
yyyank (copy)
ppaste below
Table 8: Change text
cwchange word
ccerase a line and insert
cchange to end of line
Table 9: Search
/search
nrepeat search
Nreverse search
vi-editor.1550935499.txt.gz · Last modified: 2021/09/19 17:58 (external edit)