.de TS
.br
.if !\\n(1T .RT
.ul 0
.ti \\n(.iu
.if t .sp 0.25
.if n .sp
.if \\$1H .TQ
.nr IX 1
..
.nr PS 9
.ps 9
.nr VS 11
.vs 11
.nr HM .50i
.nr FM .25i
.nr PO 0
.po 0
.nr LL 3.5i
.ll 3.5i
.de nc
.bp
..
.de h
.LG
.B
\\$1
.R
.NL
..
.LG
.LG
.B
.ce
Ex Quick Reference
.R
.NL
.LP
.LP
.h "Entering ex"
.TS
aw(1.4i)b aw(1.8i).
% ex \fIname\fP	edit \fIname\fP, start at end
% ex +\fIn\fP \fIname\fP	... at line \fIn\fP
% ex \-t \fItag\fP	start at \fItag\fP
% ex \-r	list saved files
% ex \-r \fIname\fP	recover file \fIname\fP
% ex \fIname\fP ...	edit first; rest via \fB:n\fP
.TE
.h "Ex states"
.TS
lw(1i) lw(2.0i).
Command	T{
Normal and initial state.  Input prompted for by \fB:\fP.
Your kill character cancels partial command.
T}
Insert	T{
Entered by \fBa\fP \fBi\fP and \fBc\fP.
Arbitrary text then terminates with line having only \fB.\fP
character on it or abnormally with interrupt.
T}
Open/visual	T{
Entered by \fBo\fP or \fBv\fP, terminates with \fBq\fP
or two successive interrupts.
T}
.TE
.h "Ex commands"
.TS
lw(.45i) lw(.08i)b lw(.45i) lw(.08i)b lw(.45i) lw(.08i)b.
append	a	next	n	substitute	s
args	ar	number	nu	undo	u
change	c	open	o	version	ve
copy	co	preserve	pre	visual	vi
delete	d	print	p	write	w
edit	e	put	pu	yank	ya
file	f	quit	q	\fIwindow\fP	z
global	g	read	re	\fIescape\fP	!
insert	i	recover	rec	\fIlshift\fP	<
join	j	rewind	rew	\fIprint next\fP	\fRCR\fP
list	l	set	se	\fIresubst\fP	&
mark	ma	shell	sh	\fIrshift\fP	>
move	m	source	so	\fIscroll\fP	^D
.TE
.h "Ex command addresses"
.TS
lw(.3i)b lw(0.8i) lw(.3i)b lw(0.8i).
\fIn\fP	line \fIn\fP	/\fIpat\fP	next with \fIpat\fP
\&.	current	?\fIpat\fP	previous with \fIpat\fP
$	last	\fIx\fP-\fIn\fP	\fIn\fP before \fIx\fP
+	next	\fIx\fP,\fIy\fP	\fIx\fP through \fIy\fP
\-	previous	\(aa\fIx\fP	marked with \fIx\fP
+\fIn\fP	\fIn\fP forward	\(aa\(aa	previous context
.TE
.nc
.h "Specifying terminal type"
.TS
aw(1.7i)b aw(1.5i).
% setenv TERM \fItype\fP	\fIcsh\fP and all version 6
$ TERM=\fItype\fP	\fIsh\fP in Version 7
.TE
.h "Some terminal types"
.TS
lw(.4i) lw(.4i) lw(.4i) lw(.4i) lw(.4i).
2621	43	adm31	dw1	i100
2645	733	adm3a	dw2	mime
300s	745	c100	gt40	owl
33	act4	dm1520	gt42	t1061
37	act5	dm2500	h1500	vt52
4014	adm3	dm3025	h1510
.TE
.h "Initializing options"
.TS
lw(.9i)b aw(1.5i).
\&.exrc	place \fBset\fP's here in \s-2HOME\s0 directory
set \fIx\fP	enable option
set no\fIx\fP	disable option
set \fIx\fP=\fIval\fP	give value \fIval\fP
set	show changed options
set \fIx\fP?	show value of option \fIx\fP
.TE
.h "Useful options"
.TS
lw(.9i)b lw(.3i) lw(1.0i).
autoindent	ai	supply indent
beautify	bf	discard nonprinting chars
ignorecase	ic	in scanning
lisp		\fB( ) { }\fP are s-exp's
list		print ^I for tab, $ at end
magic		\fB. [ *\fP special in patterns
number	nu	number lines
paragraphs	para	macro names which start ...
redraw		simulate smart terminal
sections	sect	macro names ...
shiftwidth	sw	for \fB< >\fP, and input \fB^D ^T\fP
showmatch	sm	to \fB)\fP and \fB}\fP as typed
slowopen	slow	choke updates during insert
wrapscan	ws	around end of buffer?
wrapmargin	wm	automatic line splitting
.TE
.LP
.h "Scanning pattern formation"
.TS
aw(.9i)b aw(1.0i).
\(ua	beginning of line
$	end of line
\fB.\fR	any character
\e<	beginning of word
\e>	end of word
[\fIstr\fP]	any char in \fIstr\fP
[\(ua\fIstr\fP]	... not in \fIstr\fP
[\fIx\-y\fP]	... between \fIx\fP and \fIy\fP
*	any number of preceding
.TE
.nc
.LP
.LG
.LG
.B
.ce
Vi Quick Reference
.NL
.R
.LP
.LP
.h "Starting vi"
.TS
aw(1.4i)b aw(1.8i).
% vi \fIname\fP	edit \fIname\fP at top
% vi +\fIn\fP \fIname\fP	... at line \fIn\fP
% vi + \fIname\fP	... at end
% vi \-r	list saved files
% vi \-r \fIname\fP	recover file \fIname\fP
% vi \fIname\fP ...	edit first; rest via \fB:n\fP
% vi \-t \fItag\fP	start at \fItag\fP
.TE
.h "The display"
.TS
lw(.75i) lw(2.2i).
Last line	T{
Error messages, echoing input to \fB: / ?\fP and \fB!\fR,
feedback about i/o and large changes.
T}
@ lines	On screen only, not in file.
~ lines	Lines past end of file.
^\fIx\fP	Control characters, ^? is delete.
tabs	Expand to spaces, cursor at last.
.TE
.LP
.h "Vi states"
.TS
lw(.75i) lw(2.2i).
Command	T{
Normal and initial state.  Others return here.
ESC (escape) cancels partial command.
T}
Insert	T{
Entered by \fBa i A I o O c C s S\fP \fBR\fP.
Arbitrary text then terminates with ESC character,
or abnormally with interrupt.
T}
Last line	T{
Reading input for \fB: / ?\fP or \fB!\fP; terminate
with ESC or CR to execute, interrupt to cancel.
T}
.TE
.h "Counts before vi commands"
.TS
lw(1.5i) lw(1.7i)b.
new window size	:  /  ?  [[  ]]  ^F  ^B  \(ga  \(aa
line/column number	z  G  |	
scroll amount	^D  ^U
replicate insert	a  i  A  I
repeat effect	\fRmost rest\fP
.TE
.h "Simple commands"
.TS
lw(1.5i)b lw(1.7i).
dw	delete a word
de	... leaving punctuation
dd	delete a line
3dd	... 3 lines
i\fItext\fP\fRESC\fP	insert text \fIabc\fP
cw\fInew\fP\fRESC\fP	change word to \fInew\fP
ea\fIs\fP\fRESC\fP	pluralize word
xp	transpose characters
.TE
.nc
.h "Interrupting, cancelling"
.TS
aw(0.75i)b aw(1.6i).
ESC	end insert or incomplete cmd
^?	(delete or rubout) interrupts
^L	reprint screen if \fB^?\fR scrambles it
.TE
.h "File manipulation"
.TS
aw(0.75i)b aw(1.6i).
:w	write back changes
:wq	write and quit
:q	quit
:q!	quit, discard changes
:e \fIname\fP	edit file \fIname\fP
:e!	reedit, discard changes
:e + \fIname\fP	edit, starting at end
:e +\fIn\fR	edit starting at line \fIn\fR
:e #	edit alternate file
^\(ua	synonym for \fB:e #\fP
:w \fIname\fP	write file \fIname\fP
:w! \fIname\fP	overwrite file \fIname\fP
:sh	run shell, then return
:!\fIcmd\fP	run \fIcmd\fR, then return
:n	edit next file in arglist
:n \fIargs\fP	specify new arglist
:f	show current file and line
^G	synonym for \fB:f\fP
:ta \fItag\fP	to tag file entry \fItag\fP
^]	\fB:ta\fP, following word is \fItag\fP
.TE
.h "Positioning within file"
.TS
aw(0.75i)b aw(1.6i).
^F	forward screenful
^B	backward screenful
^D	scroll down half screen
^U	scroll up half screen
G	goto line (end default)
/\fIpat\fR	next line matching \fIpat\fR
?\fIpat\fR	prev line matching \fIpat\fR
n	repeat last \fB/\fR or \fB?\fR
N	reverse last \fB/\fR or \fB?\fR
/\fIpat\fP/+\fIn\fP	n'th line after \fIpat\fR
?\fIpat\fP?\-\fIn\fP	n'th line before \fIpat\fR
]]	next section/function
[[	previous section/function
%	find matching \fB( ) {\fP or \fB}\fP
.TE
.h "Adjusting the screen"
.TS
aw(0.75i)b aw(1.6i).
^L	clear and redraw
^R	retype, eliminate @ lines
z\fRCR\fP	redraw, current at window top
z\-	... at bottom
z\|.	... at center
/\fIpat\fP/z\-	\fIpat\fP line at bottom
z\fIn\fP\|.	use \fIn\fP line window
.TE
.nc
.h "Marking and returning
.TS
aw(0.5i)b aw(2.0i).
\(ga\(ga	previous context
\(aa\(aa	... at first non-white in line
m\fIx\fP	mark position with letter \fIx\fP
\(ga\fIx\fP	to mark \fIx\fP
\(aa\fIx\fP	... at first non-white in line
.TE
.h "Line positioning"
.TS
aw(0.5i)b aw(2.0i).
H	home window line
L	last window line
M	middle window line
+	next line, at first non-white
\-	previous line, at first non-white
\fRCR\fP	return, same as +
^N	next line, same column
^P	previous line, same column
\fBLF\fP	linefeed, same as \fB^N\fP
.TE
.h "Character positioning"
.TS
aw(0.5i)b aw(2.0i).
\(ua	first non white
0	beginning of line
$	end of line
\fRspace\fP	forward
^H	backwards
h	same as \fB^H\fP
f\fIx\fP	find \fIx\fP forward
F\fIx\fP	\fBf\fR backward
t\fIx\fP	upto \fIx\fP forward
T\fIx\fP	back upto \fIx\fP
;	repeat last \fBf F t\fP or \fBT\fP
,	inverse of \fB;\fP
|	to specified column
%	find matching \fB( { )\fP or \fB}\fR
.TE
.h "Words, sentences, paragraphs"
.TS
aw(0.5i)b aw(2.0i).
w	word forward
b	back word
e	end of word
)	to next sentence
}	to next paragraph
(	back sentence
{	back paragraph
W	blank delimited word
B	back \fBW\fP
E	to end of \fBW\fP
.TE
.h "Commands for \s-2LISP\s0"
.TS
aw(0.5i)b aw(2.0i).
)	Forward s-expression
}	... but don't stop at atoms
(	Back s-expression
{	... but don't stop at atoms
.TE
.nc
.h "Corrections during insert"
.TS
aw(.5i)b aw(2.0i).
^H	erase last character
^W	erases last word
\fRerase\fP	your erase, same as \fB^H\fP
\fRkill\fP	your kill, erase input this line
\e	escapes \fB^H\fR, your erase and kill
\fRESC\fP	ends insertion, back to command
^?	interrupt, terminates insert
^D	backtab over \fIautoindent\fP
\(ua^D	kill \fIautoindent\fP, save for next
0^D	... but at margin next also
^Q	quote non-printing character
^T	\fIshiftwidth\fP forward tab
.TE
.h "Insert and replace"
.TS
aw(.5i)b aw(2.0i).
a	append after cursor
i	insert before
A	append at end of line
I	insert before first non-blank
o	open line below
O	open above
r\fIx\fP	replace single char with \fIx\fP
R	replace characters
.TE
.h "Operators (double to affect lines)"
.TS
aw(0.5i)b aw(2.0i).
d	delete
c	change
<	left shift
>	right shift
!	filter through command
\&\=	indent for \s-2LISP\s0
y	yank lines to buffer
.TE
.h "Miscellaneous operations"
.TS
aw(0.5i)b aw(2.0i).
C	change rest of line
D	delete rest of line
s	substitute chars
S	substitute lines
J	join lines
x	delete characters
X	... before cursor
Y	yank lines
.TE
.h "Yank and put"
.TS
aw(0.5i)b aw(2.0i).
p	put back lines
P	put before
"\fIx\fPp	put from buffer \fIx\fP
"\fIx\fPy	yank to buffer \fIx\fP
"\fIx\fPd	delete into buffer \fIx\fP
.TE
.h "Undo, redo, retrieve"
.TS
aw(0.5i)b aw(2.0i).
u	undo last change
U	restore current line
\fB.\fP	repeat last change
"\fId\fP\|p	retrieve \fId\fP'th last delete
.TE
