BSD 4_2 development
[unix-history] / usr / doc / ex / vi.summary
CommitLineData
2ec95760
C
1.ds CH
2.ds CF
3.de TS
4.br
5.if !\\n(1T .RT
6.ul 0
7.ti \\n(.iu
8.if t .sp 0.25
9.if n .sp
10.if \a\\$1\aH\a .TQ
11.nr IX 1
12..
13.nr PS 9
14.ps 9
15.nr VS 11
16.vs 11
17.nr HM .50i
18.nr FM .25i
19.nr PO 0
20.po 0
21.nr LL 3.5i
22.ll 3.5i
23.de nc
24.bp
25..
26.de h
27.LG
28.B
29\\$1
30.R
31.NL
32..
33.LG
34.LG
35.B
36.ce
37Ex Quick Reference
38.R
39.NL
40.LP
41.LP
42.h "Entering/leaving ex"
43.TS
44aw(1.4i)b aw(1.8i).
45% ex \fIname\fP edit \fIname\fP, start at end
46% ex +\fIn\fP \fIname\fP ... at line \fIn\fP
47% ex \-t \fItag\fP start at \fItag\fP
48% ex \-r list saved files
49% ex \-r \fIname\fP recover file \fIname\fP
50% ex \fIname\fP ... edit first; rest via \fB:n\fP
51% ex \-R \fIname\fP read only mode
52: x exit, saving changes
53: q! exit, discarding changes
54.TE
55.h "Ex states"
56.TS
57lw(1i) lw(2.0i).
58Command T{
59Normal and initial state. Input prompted for by \fB:\fP.
60Your kill character cancels partial command.
61T}
62Insert T{
63Entered by \fBa\fP \fBi\fP and \fBc\fP.
64Arbitrary text then terminates with line having only \fB.\fP
65character on it or abnormally with interrupt.
66T}
67Open/visual T{
68Entered by \fBopen\fP or \fBvi\fP, terminates with \fBQ\fP
69or ^\e.
70T}
71.TE
72.h "Ex commands"
73.TS
74lw(.45i) lw(.08i)b lw(.45i) lw(.08i)b lw(.45i) lw(.08i)b.
75abbrev ab next n unabbrev una
76append a number nu undo u
77args ar open o unmap unm
78change c preserve pre version ve
79copy co print p visual vi
80delete d put pu write w
81edit e quit q xit x
82file f read re yank ya
83global g recover rec \fIwindow\fP z
84insert i rewind rew \fIescape\fP !
85join j set se \fIlshift\fP <
86list l shell sh \fIprint next\fP \fRCR\fP
87map source so \fIresubst\fP &
88mark ma stop st \fIrshift\fP >
89move m substitute s \fIscroll\fP ^D
90.TE
91.h "Ex command addresses"
92.TS
93lw(.3i)b lw(0.8i) lw(.3i)b lw(0.8i).
94\fIn\fP line \fIn\fP /\fIpat\fP next with \fIpat\fP
95\&. current ?\fIpat\fP previous with \fIpat\fP
96$ last \fIx\fP-\fIn\fP \fIn\fP before \fIx\fP
97+ next \fIx\fP,\fIy\fP \fIx\fP through \fIy\fP
98\- previous \(aa\fIx\fP marked with \fIx\fP
99+\fIn\fP \fIn\fP forward \(aa\(aa previous context
100% 1,$
101.TE
102.nc
103.h "Specifying terminal type"
104.TS
105aw(1.7i)b aw(1.5i).
106% setenv TERM \fItype\fP \fIcsh\fP and all version 6
107$ TERM=\fItype\fP; export TERM \fIsh\fP in Version 7
108See also \fItset\fR(1)
109.TE
110.h "Some terminal types"
111.TS
112lw(.4i) lw(.4i) lw(.4i) lw(.4i) lw(.4i).
1132621 43 adm31 dw1 h19
1142645 733 adm3a dw2 i100
115300s 745 c100 gt40 mime
11633 act4 dm1520 gt42 owl
11737 act5 dm2500 h1500 t1061
1184014 adm3 dm3025 h1510 vt52
119.TE
120.h "Initializing options"
121.TS
122lw(.9i)b aw(1.5i).
123EXINIT place \fBset\fP's here in environment var.
124set \fIx\fP enable option
125set no\fIx\fP disable option
126set \fIx\fP=\fIval\fP give value \fIval\fP
127set show changed options
128set all show all options
129set \fIx\fP? show value of option \fIx\fP
130.TE
131.h "Useful options"
132.TS
133lw(.9i)b lw(.3i) lw(1.0i).
134autoindent ai supply indent
135autowrite aw write before changing files
136ignorecase ic in scanning
137lisp \fB( ) { }\fP are s-exp's
138list print ^I for tab, $ at end
139magic \fB. [ *\fP special in patterns
140number nu number lines
141paragraphs para macro names which start ...
142redraw simulate smart terminal
143scroll command mode lines
144sections sect macro names ...
145shiftwidth sw for \fB< >\fP, and input \fB^D\fP
146showmatch sm to \fB)\fP and \fB}\fP as typed
147slowopen slow choke updates during insert
148window visual mode lines
149wrapscan ws around end of buffer?
150wrapmargin wm automatic line splitting
151.TE
152.LP
153.h "Scanning pattern formation"
154.TS
155aw(.9i)b aw(1.0i).
156\(ua beginning of line
157$ end of line
158\fB.\fR any character
159\e< beginning of word
160\e> end of word
161[\fIstr\fP] any char in \fIstr\fP
162[\(ua\fIstr\fP] ... not in \fIstr\fP
163[\fIx\-y\fP] ... between \fIx\fP and \fIy\fP
164* any number of preceding
165.TE
166.nc
167.LP
168.LG
169.LG
170.B
171.ce
172Vi Quick Reference
173.NL
174.R
175.LP
176.LP
177.h "Entering/leaving vi"
178.TS
179aw(1.4i)b aw(1.8i).
180% vi \fIname\fP edit \fIname\fP at top
181% vi +\fIn\fP \fIname\fP ... at line \fIn\fP
182% vi + \fIname\fP ... at end
183% vi \-r list saved files
184% vi \-r \fIname\fP recover file \fIname\fP
185% vi \fIname\fP ... edit first; rest via \fB:n\fP
186% vi \-t \fItag\fP start at \fItag\fP
187% vi +/\fIpat\fP \fIname\fP search for \fIpat\fP
188% view \fIname\fP read only mode
189ZZ exit from vi, saving changes
190^Z stop vi for later resumption
191.TE
192.h "The display"
193.TS
194lw(.75i) lw(2.2i).
195Last line T{
196Error messages, echoing input to \fB: / ?\fP and \fB!\fR,
197feedback about i/o and large changes.
198T}
199@ lines On screen only, not in file.
200~ lines Lines past end of file.
201^\fIx\fP Control characters, ^? is delete.
202tabs Expand to spaces, cursor at last.
203.TE
204.LP
205.h "Vi states"
206.TS
207lw(.75i) lw(2.2i).
208Command T{
209Normal and initial state. Others return here.
210ESC (escape) cancels partial command.
211T}
212Insert T{
213Entered by \fBa i A I o O c C s S\fP \fBR\fP.
214Arbitrary text then terminates with ESC character,
215or abnormally with interrupt.
216T}
217Last line T{
218Reading input for \fB: / ?\fP or \fB!\fP; terminate
219with ESC or CR to execute, interrupt to cancel.
220T}
221.TE
222.h "Counts before vi commands"
223.TS
224lw(1.5i) lw(1.7i)b.
225line/column number z G |
226scroll amount ^D ^U
227replicate insert a i A I
228repeat effect \fRmost rest\fP
229.TE
230.h "Simple commands"
231.TS
232lw(1.5i)b lw(1.7i).
233dw delete a word
234de ... leaving punctuation
235dd delete a line
2363dd ... 3 lines
237i\fItext\fP\fRESC\fP insert text \fIabc\fP
238cw\fInew\fP\fRESC\fP change word to \fInew\fP
239ea\fIs\fP\fRESC\fP pluralize word
240xp transpose characters
241.TE
242.nc
243.h "Interrupting, cancelling"
244.TS
245aw(0.75i)b aw(1.6i).
246ESC end insert or incomplete cmd
247^? (delete or rubout) interrupts
248^L reprint screen if \fB^?\fR scrambles it
249.TE
250.h "File manipulation"
251.TS
252aw(0.75i)b aw(1.6i).
253:w write back changes
254:wq write and quit
255:q quit
256:q! quit, discard changes
257:e \fIname\fP edit file \fIname\fP
258:e! reedit, discard changes
259:e + \fIname\fP edit, starting at end
260:e +\fIn\fR edit starting at line \fIn\fR
261:e # edit alternate file
262^\(ua synonym for \fB:e #\fP
263:w \fIname\fP write file \fIname\fP
264:w! \fIname\fP overwrite file \fIname\fP
265:sh run shell, then return
266:!\fIcmd\fP run \fIcmd\fR, then return
267:n edit next file in arglist
268:n \fIargs\fP specify new arglist
269:f show current file and line
270^G synonym for \fB:f\fP
271:ta \fItag\fP to tag file entry \fItag\fP
272^] \fB:ta\fP, following word is \fItag\fP
273.TE
274.h "Positioning within file"
275.TS
276aw(0.75i)b aw(1.6i).
277^F forward screenfull
278^B backward screenfull
279^D scroll down half screen
280^U scroll up half screen
281G goto line (end default)
282/\fIpat\fR next line matching \fIpat\fR
283?\fIpat\fR prev line matching \fIpat\fR
284n repeat last \fB/\fR or \fB?\fR
285N reverse last \fB/\fR or \fB?\fR
286/\fIpat\fP/+\fIn\fP n'th line after \fIpat\fR
287?\fIpat\fP?\-\fIn\fP n'th line before \fIpat\fR
288]] next section/function
289[[ previous section/function
290% find matching \fB( ) {\fP or \fB}\fP
291.TE
292.h "Adjusting the screen"
293.TS
294aw(0.75i)b aw(1.6i).
295^L clear and redraw
296^R retype, eliminate @ lines
297z\fRCR\fP redraw, current at window top
298z\- ... at bottom
299z\|. ... at center
300/\fIpat\fP/z\- \fIpat\fP line at bottom
301z\fIn\fP\|. use \fIn\fP line window
302^E scroll window down 1 line
303^Y scroll window up 1 line
304.TE
305.nc
306.h "Marking and returning
307.TS
308aw(0.5i)b aw(2.0i).
309\(ga\(ga previous context
310\(aa\(aa ... at first non-white in line
311m\fIx\fP mark position with letter \fIx\fP
312\(ga\fIx\fP to mark \fIx\fP
313\(aa\fIx\fP ... at first non-white in line
314.TE
315.h "Line positioning"
316.TS
317aw(0.5i)b aw(2.0i).
318H home window line
319L last window line
320M middle window line
321+ next line, at first non-white
322\- previous line, at first non-white
323\fRCR\fP return, same as +
324\(da \fRor\fP j next line, same column
325\(ua \fRor\fP k previous line, same column
326.TE
327.h "Character positioning"
328.TS
329aw(0.5i)b aw(2.0i).
330\(ua first non white
3310 beginning of line
332$ end of line
333h \fRor\fP \(-> forward
334l \fRor\fP \(<- backwards
335^H same as \fB\(<-\fP
336\fRspace\fP same as \fB\(->\fP
337f\fIx\fP find \fIx\fP forward
338F\fIx\fP \fBf\fR backward
339t\fIx\fP upto \fIx\fP forward
340T\fIx\fP back upto \fIx\fP
341; repeat last \fBf F t\fP or \fBT\fP
342, inverse of \fB;\fP
343| to specified column
344% find matching \fB( { )\fP or \fB}\fR
345.TE
346.h "Words, sentences, paragraphs"
347.TS
348aw(0.5i)b aw(2.0i).
349w word forward
350b back word
351e end of word
352) to next sentence
353} to next paragraph
354( back sentence
355{ back paragraph
356W blank delimited word
357B back \fBW\fP
358E to end of \fBW\fP
359.TE
360.h "Commands for \s-2LISP\s0"
361.TS
362aw(0.5i)b aw(2.0i).
363) Forward s-expression
364} ... but don't stop at atoms
365( Back s-expression
366{ ... but don't stop at atoms
367.TE
368.nc
369.h "Corrections during insert"
370.TS
371aw(.5i)b aw(2.0i).
372^H erase last character
373^W erases last word
374\fRerase\fP your erase, same as \fB^H\fP
375\fRkill\fP your kill, erase input this line
376\e escapes \fB^H\fR, your erase and kill
377\fRESC\fP ends insertion, back to command
378^? interrupt, terminates insert
379^D backtab over \fIautoindent\fP
380\(ua^D kill \fIautoindent\fP, save for next
3810^D ... but at margin next also
382^V quote non-printing character
383.TE
384.h "Insert and replace"
385.TS
386aw(.5i)b aw(2.0i).
387a append after cursor
388i insert before
389A append at end of line
390I insert before first non-blank
391o open line below
392O open above
393r\fIx\fP replace single char with \fIx\fP
394R replace characters
395.TE
396.h "Operators (double to affect lines)"
397.TS
398aw(0.5i)b aw(2.0i).
399d delete
400c change
401< left shift
402> right shift
403! filter through command
404\&\= indent for \s-2LISP\s0
405y yank lines to buffer
406.TE
407.h "Miscellaneous operations"
408.TS
409aw(0.5i)b aw(2.0i).
410C change rest of line
411D delete rest of line
412s substitute chars
413S substitute lines
414J join lines
415x delete characters
416X ... before cursor
417Y yank lines
418.TE
419.h "Yank and put"
420.TS
421aw(0.5i)b aw(2.0i).
422p put back lines
423P put before
424"\fIx\fPp put from buffer \fIx\fP
425"\fIx\fPy yank to buffer \fIx\fP
426"\fIx\fPd delete into buffer \fIx\fP
427.TE
428.h "Undo, redo, retrieve"
429.TS
430aw(0.5i)b aw(2.0i).
431u undo last change
432U restore current line
433\fB.\fP repeat last change
434"\fId\fP\|p retrieve \fId\fP'th last delete
435.TE