VI and UNIX Quick Reference Sheet


vi Editor Tips:

From Unix prompt (%) enter:

vi filename

These are the basic vi editor commands. For a more detailed list refer to any UNIX manual.

Modes:

Movement:

(Must be in command mode)

j -- move down one line
h -- move to the left one character
k -- move up one line
l -- move to the right one character

Note: the keypad arrow keys generally work for movement as well.

Entering/Deleting Text:

(Must be entered from command mode. Puts you in input mode.)

a -- append after cursor
A -- append at end of line
i -- insert before cursor (most commonly used to start new file)
I -- insert at beginning of line
o -- create new line below the current line
O -- create new line above the current line

(Must be in command mode.)

dd -- delete current line, 3dd deletes 3 lines
D -- delete from cursor to end of line
u -- undo last change
x -- delete character at cursor, 4x deletes 4 characters

Exiting/Misc Commands:

(Must be enterd from last line mode.)

q -- quit if saved or no changes
q! -- quit without writing changes
w -- write the changes to file
wq -- write changes to file and exit
set showmode -- display when in input/insert mode
r filename -- read file in at cursor position


Common UNIX Commands:

Note:Unix is case sensitive - upper or lower case letters make a difference! All commands listed below are entered at the Unix prompt, which on our system consists of your login name, an event number and a percent sign (%).

passwd -- Use to change your current password. You will be prompted for the old and
new passwords.
ls -- List current directory
ls -l -- Long listing
ls -a -- List all files (and .files)
cp fileA fileB -- Copy fileA to fileB
mv fileA fileB -- Rename fileA to fileB
mkdir xyz -- Make a directory named xyz
rm fileA -- remove a file called fileA
cd xyz -- change (down) to directory xyz
cd .. -- move back(up) one directory
cd / -- move to the root(/) directory
vi fileA -- start the vi editor for new or existing file named fileA
h -- display command history since login
!! -- recall last command
!n -- recall command number n


written by Jason Russell; 6/95