vi
vi
Developed by Bill Joy in (approx) 1978 as a replacement for ed/ex
ed
vi
vi
vi
Result:
emacs: time: 25.2 real 11.5 user 1.2 sys vi: time: 9.4 real 0.5 user 0.3 sys
"Vi is small, fast, and easy to use. Emacs is huge, slow and easy to use"
- Scott McMahon, softbase@mercury.interpath.net, 1998
"Which editor was used to write the first version of emacs?"
- Me, jas@cse.unsw.edu.au, August 2000
vi
vi
vi
vi
[Esc]
vi
vi
Many Unix applications that need to invoke an editor, invoke vi
The EDITOR
But some applications ignore even that and suddenly ... you're in vi
vi
[Esc]
:wq
ZZ
vi
:q!
vi
^H
[ESC]
ex
ed/ex
:
[Enter]
h j k l |
left, down, up, right (obvious!) | |
w b e |
forward / backward / move.to.end.of one "word" | |
^ 0 $ |
first.non.blank / beginning / end of current line | |
} { |
forward / backward by one "block" | |
^F ^B |
forward / backward by one "page" | |
G |
go to end of buffer | |
ddd G |
go to line ddd |
All movements can be preceded by a count
(e.g. 10w
/ |
move to next occurrence of pattern in file | |
? |
move to prev occurrence of pattern in file | |
f |
move to next occurrence of c in current line | |
F |
move to prev occurrence of c in current line |
x |
delete character under cursor | |
i |
insert text immediately before cursor | |
a |
append text immediately after cursor | |
o |
open a new line below current line | |
O |
open a new line above current line | |
s |
subsitute text for character at cursor | |
S |
subsitute text for whole of current line |
d |
delete text from old to new cursor positions |
|
c |
change text from old to new cursor positions | |
! |
filter text from old to new cursor through cmd | |
< > |
left / right shift text from old to new cursor | |
y |
grab a copy of text from old to new cursor posn |
Doubling a change command (e.g. dd
Changed text is placed into a buffer, from where it can be retrieved.
dw | delete to start of next word | |
d0 | delete to start of line | |
dH | delete to top of page | |
d} | delete to end of "block" | |
d/abc | delete up to next abc | |
dd | delete current line | |
cc | change current line (like S | |
!}fmt | format a paragraph |
u |
undo last change | |
U |
undo all recent changes to current line | |
:e! |
quit from vi |
|
:e! |
undo all changes to file and start again |
Later versions of vi
u
p |
paste saved text after cursor | |
P |
paste saved text before cursor |
Precise paste effect depends on whether it was part or multiple lines saved.
.
Leads to an idiom for skipping through file making similar changes:
/
cw
n
.
:%s/pattern/replacement/g
vi
:set all
map # :w:!ispell -x %:e!
ab SYN synchronised
"ayy "ap
VI
vim
Produced: 10 Aug 2000