The vi Editor

The following are keyboard commands used in the "vi" editor:
H move cursor to first line of screen (Home)
M move cursor to middle of screen
L move cursor to last line of screen
j move cursor down one line
k move cursor up one line
l move cursor right one character
h move cursor left one character
w move cursor forward one word
b move cursor back one word
e move cursor to end of word
dw delete current word
dd delete current line
d<cr> delete two lines
x delete character
xp transposes (swaps) characters "ea" for "ae"
D delete from cursor to end of line
u undo last command (toggles)
r replace character
R replace continuously one character at a time <esc>
G go to last line in file
35G go to line 35
^ go to beginning of current line
$ go to end of current line
J join current line and next
- go to first character of previous line
. repeat previous command (dot)
~ change case -- upper <-> lower
y yank word(s)
Y yank line(s)
p "paste" text after cursor
P "paste" text before cursor
ZZ Write and Quit


Cursor Movement (in "escape" mode)

Move Move Move Move
Left Down Up Right
h j k l/sp
B/B + - w/W


The following commands put the editor in the insert/add mode:

i insert text (at cursor)
I insert text at the beginning of the current line
a add text (following cursor)
A add text to the end of the current line
o open line below cursor
O open line above cursor
c change (must be used with a movement key like "w")
C change to end of line
s substitute for present character
S Substitute for entire line

[ NOTE: When you type one of these characters, everything you type goes into the file until you hit the <escape> key ]


(c)Copyright 1985, 1996 by Bruce Jones
Anyone is free to reproduce any of these documents in their entirety or parts thereof providing:
  1. Sections used are reproduced entirely and without alteration
  2. The following page footer is reproduced on each page:
    BJ's UNIX Primer - (c) Bruce Jones - 1985, 1996
  3. Full credit is noted somewhere in the reproduction
Bruce Jones 			Department of Communication
bjones@ucsd.edu			University of California, San Diego
(619) 534-0417/4410		9500 Gilman Drive
FAX (619) 534-7315		La Jolla, Ca. 92093-0503

Comments to: bjones@ucsd.edu


Return to:
Bruce Jones Homepage
BJ's Unix Primer Index
The CommWeb Homepage

This page last updated on: Feb 3 1997