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