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