1vi(1)                            User Commands                           vi(1)
2
3
4

NAME

6       vi, view, vedit - screen-oriented (visual) display editor based on ex
7

SYNOPSIS

9       /usr/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]] [-S]
10            [-t tag] [-v] [-V] [-x] [-wn] [-C]
11            [+command | -c command] filename...
12
13
14       /usr/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]] [-S]
15            [-t tag] [-v] [-V] [-x] [-wn] [-C]
16            [+command | -c command] filename...
17
18
19       /usr/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]] [-S]
20            [-t tag] [-v] [-V] [-x] [-wn] [-C]
21            [+command | -c command] filename...
22
23
24       /usr/xpg4/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]]
25            [-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
26            [+command | -c command] filename...
27
28
29       /usr/xpg4/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]]
30            [-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
31            [+command | -c command] filename...
32
33
34       /usr/xpg4/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]]
35            [-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
36            [+command | -c command] filename...
37
38
39       /usr/xpg6/bin/vi [-| -s] [-l] [-L] [-R] [-r [filename]]
40            [-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
41            [+command | -c command] filename...
42
43
44       /usr/xpg6/bin/view [-| -s] [-l] [-L] [-R] [-r [filename]]
45            [-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
46            [+command | -c command] filename...
47
48
49       /usr/xpg6/bin/vedit [-| -s] [-l] [-L] [-R] [-r [filename]]
50            [-S] [-t tag] [-v] [-V] [-x] [-wn] [-C]
51            [+command | -c command] filename...
52
53

DESCRIPTION

55       The  vi  (visual) utility is a display-oriented text editor based on an
56       underlying line editor ex. It is possible to use the command mode of ex
57       from  within  vi  and to use the command mode of vi from within ex. The
58       visual commands are described on this manual page; how to  set  options
59       (like  automatically  numbering  lines and automatically starting a new
60       output line when you type carriage return) and all ex line editor  com‐
61       mands are described on the ex(1) manual page.
62
63
64       When  using  vi, changes you make to the file are reflected in what you
65       see on your terminal screen. The position of the cursor on  the  screen
66       indicates the position within the file.
67
68
69       The  view invocation is the same as vi except that the readonly flag is
70       set.
71
72
73       The vedit invocation is intended for beginners. It is the  same  as  vi
74       except  that the report flag is set to 1, the showmode and novice flags
75       are set, and magic is turned off. These  defaults  make  it  easier  to
76       learn how to use vi.
77

OPTIONS

79       The following options are supporrted:
80
81   Invocation Options
82       The following invocation options are interpreted by vi (previously doc‐
83       umented options are discussed under NOTES):
84
85       | -s                   Suppresses all interactive user feedback. This
86                                is useful when processing editor scripts.
87
88
89       -C                       Encryption  option.  Same  as  the  -x option,
90                                except that vi simulates the C command of  ex.
91                                The  C  command  is  like the X command of ex,
92                                except that all text read  in  is  assumed  to
93                                have been encrypted.
94
95
96       -l                       Sets up for editing LISP programs.
97
98
99       -L                       Lists  the  name  of  all  files  saved as the
100                                result of an editor or system crash.
101
102
103       -r filename              Edits  filename  after  an  editor  or  system
104                                crash.  (Recovers the version of filename that
105                                was in the buffer when the crash occurred.)
106
107
108       -R                       Readonly mode. The readonly flag is set,  pre‐
109                                venting accidental overwriting of the file.
110
111
112       -S                       This option is used in conjunction with the -t
113                                tag option to tell vi that the tags  file  can
114                                not  be  sorted and that, if the binary search
115                                (which relies on a sorted tags file)  for  tag
116                                fails  to  find  it,  the  much  slower linear
117                                search should also be done. Since  the  linear
118                                search  is  slow,  users  of  large tags files
119                                should ensure that the tags files  are  sorted
120                                rather  than  use  this flag. Creation of tags
121                                files normally produces sorted tags files. See
122                                ctags(1) for more information on tags files.
123
124
125       -t tag                   Edits the file containing tag and position the
126                                editor at its definition. It is  an  error  to
127                                specify more than one -t option.
128
129
130       -v                       Starts  up in display editing state, using vi.
131                                You can achieve the same effect by typing  the
132                                vi command itself.
133
134
135       -V                       Verbose. When ex commands are read by means of
136                                standard input, the input is echoed  to  stan‐
137                                dard error. This can be useful when processing
138                                ex commands within shell scripts.
139
140
141       -wn                      Sets the default window size  to  n.  This  is
142                                useful when using the editor over a slow speed
143                                line.
144
145
146       -x                       Encryption option. When used, vi simulates the
147                                X  command  of  ex  and prompts the user for a
148                                key. This key is used to encrypt  and  decrypt
149                                text using the algorithm of the crypt command.
150                                The X  command  makes  an  educated  guess  to
151                                determine whether text read in is encrypted or
152                                not. The temporary buffer  file  is  encrypted
153                                also,  using  a transformed version of the key
154                                typed in  for  the  -x  option.  If  an  empty
155                                encryption   key  is  entered (that is, if the
156                                return key is pressed right after the prompt),
157                                the  file is not encrypted. This is a good way
158                                to decrypt a file erroneously encrypted with a
159                                mistyped  encryption  key, such as a backspace
160                                or undo key.
161
162
163       -command | -c command    Begins editing by executing the specified edi‐
164                                tor  command  (usually a search or positioning
165                                command).
166
167
168   /usr/xpg4/bin/vi and /usr/xpg6/bin/vi
169       If both the -t tag and the -c command options are  given,  the  -t  tag
170       optionis  processed first. That is, the file containing tag is selected
171       by -t and then the command is executed.
172

OPERANDS

174       The following operands are supported:
175
176       filename    A file to be edited.
177
178

COMMAND SUMMARY

180       The vi command modes are summarized in this section.
181
182   vi Modes
183       Command      Normal and initial mode. Other  modes  return  to  command
184                    mode  upon  completion.  ESC  (escape) is used to cancel a
185                    partial command.
186
187
188       Input        Entered by setting any of the following options:
189
190                      a A i I o O c C s S R
191
192
193                    Arbitrary text can then be entered. Input mode is normally
194                    terminated with the ESC character, or, abnormally, with an
195                    interrupt.
196
197
198       Last line    Reading input for : / ? or !. Terminate by typing  a  car‐
199                    riage return. An interrupt cancels termination.
200
201
202   Sample Commands
203       In  the  descriptions, CR stands for carriage return and ESC stands for
204       the escape key.
205
206       ←, →          arrow keys move the cursor
207       down-arrow
208       up-arrow
209       h j k l       same as arrow keys
210
211
212       itextESC      insert text
213
214
215       cwnewESC      change word to new
216
217
218       easESC        pluralize word (end of word; append s; escape from  input
219                     state)
220
221
222       x             delete a character
223
224
225       dw            delete a word
226
227
228       dd            delete a line
229
230
231       3dd           delete 3 lines
232
233
234       u             undo previous change
235
236
237       ZZ            exit vi, saving changes
238
239
240       :q!CR         quit, discarding changes
241
242
243       /textCR       search for text
244
245
246       ^U ^D         scroll up or down
247
248
249       :cmdCR        any ex or ed command
250
251
252   Counts Before vi Commands
253       Numbers can be typed as a prefix to some commands. They are interpreted
254       in one of these ways:
255
256       line/column number    z  G  |
257
258
259       scroll amount         ^D  ^U
260
261
262       repeat effect         most of the rest
263
264
265   Interrupting, Canceling
266       ESC    end insert or incomplete command
267
268
269       DEL    (delete or rubout) interrupts
270
271
272   File Manipulation
273       ZZ             if file modified, write and exit; otherwise, exit
274
275
276       :wCR           write back changes
277
278
279       :w!CR          forced write, if permission originally not valid
280
281
282       :qCR           quit
283
284
285       :q!CR          quit, discard changes
286
287
288       :e nameCR      edit file name
289
290
291       :e!CR          reedit, discard changes
292
293
294       :e + nameCR    edit, starting at end
295
296
297       :e +nCR        edit, starting at line n
298
299
300       :e #CR         edit alternate file
301
302
303       :e! #CR        edit alternate file, discard changes
304
305
306       :w nameCR      write file name
307
308
309       :w! nameCR     overwrite file name
310
311
312       :shCR          run shell, then return
313
314
315       :!cmdCR        run cmd, then return
316
317
318       :nCR           edit next file in arglist
319
320
321       :n argsCR      specify new arglist
322
323
324       ^G             show current file and line
325
326
327       :ta tagCR      position cursor to tag
328
329
330
331       In general, any ex or ed command (such as substitute or global) can  be
332       typed, preceded by a colon and followed by a carriage return.
333
334   Positioning Within a File
335       F             forward screen
336
337
338       ^B            backward screen
339
340
341       ^D            scroll down half screen
342
343
344       ^U            scroll up half screen
345
346
347       nG            go  to the beginning of the specified line (end default),
348                     where n is a line number
349
350
351       /pat          next line matching pat
352
353
354       ?pat          previous line matching pat
355
356
357       n             repeat last / or ? command
358
359
360       N             reverse last / or ? command
361
362
363       /pat/+n       nth line after pat
364
365
366       ?pat?−n       nth line before pat
367
368
369       ]]            next section/function
370
371
372       [[            previous section/function
373
374
375       (             beginning of sentence
376
377
378       )             end of sentence
379
380
381       {             beginning of paragraph
382
383
384       }             end of paragraph
385
386
387       %             find matching ( ) or { }
388
389
390   Adjusting the Screen
391       ^L              clear and redraw window
392
393
394       ^R              clear and redraw window if ^L is → key
395
396
397       zCR             redraw screen with current line at top of window
398
399
400       z−CR            redraw screen with current line at bottom of window
401
402
403       z.CR            redraw screen with current line at center of window
404
405
406       /pat/z−CR       move pat line to bottom of window
407
408
409       zn.CR           use n−line window
410
411
412       ^E              scroll window down one line
413
414
415       ^Y              scroll window up one line
416
417
418   Marking and Returning
419       ``          move cursor to previous context
420
421
422       a´a´        move cursor to first non-white space in line
423
424
425       mx          mark current position with the ASCII lower-case letter x
426
427
428       `x          move cursor to mark x
429
430
431       x         move cursor to first non-white space in line marked by x
432
433
434   Line Positioning
435       H             top line on screen
436
437
438       L             last line on screen
439
440
441       M             middle line on screen
442
443
444       +             next line, at first non-white space character
445
446
447       previous line, at first non-white space character
448
449
450       CR            return, same as +
451
452
453       down-arrow    next line, same column
454       or j
455
456       up-arrow      previous line, same column
457       or k
458
459   Character Positioning
460       ^            first non-white space character
461
462
463       0            beginning of line
464
465
466       $            end of line
467
468
469       l or forward
470
471
472       h or backward
473
474
475       ^H           same as (backspace)
476
477
478       space        same as (space bar)
479
480
481       fx           find next x
482
483
484       Fx           find previous x
485
486
487       tx           move to character following the next x
488
489
490       Tx           move to character following the previous x
491
492
493       ;            repeat last f, F, t, or T
494
495
496       ,            repeat inverse of last f, F, t, or T
497
498
499       n|           move to column n
500
501
502       %            find matching ( ) or { }
503
504
505   Words, Sentences, Paragraphs
506       w    forward a word
507
508
509       b    back a word
510
511
512       e    end of word
513
514
515       )    to next sentence
516
517
518       }    to next paragraph
519
520
521       (    back a sentence
522
523
524       {    back a paragraph
525
526
527       W    forward a blank-delimited word
528
529
530       B    back a blank-delimited word
531
532
533       E    end of a blank-delimited word
534
535
536   Corrections During Insert
537       ^H              erase last character (backspace)
538
539
540       ^W              erase last word
541
542
543       erase           your erase character, same as ^H (backspace)
544
545
546       kill            your kill character, erase this line of input
547
548
549       \               quotes your erase and kill characters
550
551
552       ESC             ends insertion, back to command mode
553
554
555       Control−C       interrupt, suspends insert mode
556
557
558       ^D              backtab one character; reset left margin of autoindent
559
560
561       ^^D             caret (^) followed by control-d (^D); backtab to begin‐
562                       ning of line; do not reset left margin of autoindent
563
564
565       0^D             backtab  to  beginning  of  line;  reset left margin of
566                       autoindent
567
568
569       ^V              quote non-printable character
570
571
572   Insert and Replace
573       a           append after cursor
574
575
576       A           append at end of line
577
578
579       i           insert before cursor
580
581
582       I           insert before first non-blank
583
584
585       o           open line below
586
587
588       O           open line above
589
590
591       rx          replace single character with x
592
593
594       RtextESC    replace characters
595
596
597   Operators
598       Operators are followed by a cursor motion  and  affect  all  text  that
599       would  have been moved over. For example, since w moves over a word, dw
600       deletes the word that would be moved over.  Double  the  operator,  for
601       example dd, to affect whole lines.
602
603       d    delete
604
605
606       c    change
607
608
609       y    yank lines to buffer
610
611
612       <    left shift
613
614
615       >    right shift
616
617
618       !    filter through command
619
620
621   Miscellaneous Operations
622       C    change rest of line (c$)
623
624
625       D    delete rest of line (d$)
626
627
628       s    substitute characters (cl)
629
630
631       S    substitute lines (cc)
632
633
634       J    join lines
635
636
637       x    delete characters (dl)
638
639
640       X    delete characters before cursor dh)
641
642
643       Y    yank lines (yy)
644
645
646   Yank and Put
647       Put  inserts  the  text  most recently deleted or yanked; however, if a
648       buffer is named (using the ASCII lower-case letters a - z), the text in
649       that buffer is put instead.
650
651       3yy    yank 3 lines
652
653
654       3yl    yank 3 characters
655
656
657       p      put back text after cursor
658
659
660       P      put back text before cursor
661
662
663       "xp    put from buffer x
664
665
666       "xy    yank to buffer x
667
668
669       "xd    delete into buffer x
670
671
672   Undo, Redo, Retrieve
673       u      undo last change
674
675
676       U      restore current line
677
678
679       .      repeat last change
680
681
682       "dp    retrieve d'th last delete
683
684

USAGE

686       See  largefile(5)  for  the  description of the behavior of vi and view
687       when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
688

ENVIRONMENT VARIABLES

690       See environ(5) for descriptions of the following environment  variables
691       that  affect  the  execution of vi: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
692       LC_TIME, LC_MESSAGES, NLSPATH, PATH, SHELL, and TERM.
693
694       COLUMNS    Override the system-selected horizontal screen size.
695
696
697       EXINIT     Determine a list of ex commands that are executed on  editor
698                  start-up,  before  reading the first file. The list can con‐
699                  tain multiple commands by separating them using a  vertical-
700                  line (|) character.
701
702
703       LINES      Override  the  system-selected vertical screen size, used as
704                  the number of lines in a screenful and the  vertical  screen
705                  size in visual mode.
706
707

FILES

709       /var/tmp
710
711           default  directory where temporary work files are placed; it can be
712           changed using the directory option (see the ex(1) command)
713
714
715       /usr/share/lib/terminfo/?/*
716
717           compiled terminal description database
718
719
720       /usr/lib/.COREterm/?/*
721
722           subset of compiled terminal description database
723
724

ATTRIBUTES

726       See attributes(5) for descriptions of the following attributes:
727
728   /usr/bin/vi, /usr/bin/view, /usr/bin/vedit
729       ┌─────────────────────────────┬─────────────────────────────┐
730       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
731       ├─────────────────────────────┼─────────────────────────────┤
732       │Availability                 │SUNWcsu                      │
733       ├─────────────────────────────┼─────────────────────────────┤
734       │CSI                          │Not enabled                  │
735       └─────────────────────────────┴─────────────────────────────┘
736
737   /usr/xpg4/bin/vi, /usr/xpg4/bin/view, /usr/xpg4/bin/vedit
738       ┌─────────────────────────────┬─────────────────────────────┐
739       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
740       ├─────────────────────────────┼─────────────────────────────┤
741       │Availability                 │SUNWxcu4                     │
742       ├─────────────────────────────┼─────────────────────────────┤
743       │CSI                          │Enabled                      │
744       ├─────────────────────────────┼─────────────────────────────┤
745       │Interface Stability          │Standard                     │
746       └─────────────────────────────┴─────────────────────────────┘
747
748   /usr/xpg6/bin/vi, /usr/xpg6/bin/view, /usr/xpg6/bin/vedit
749       ┌─────────────────────────────┬─────────────────────────────┐
750       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
751       ├─────────────────────────────┼─────────────────────────────┤
752       │Availability                 │SUNWxcu6                     │
753       ├─────────────────────────────┼─────────────────────────────┤
754       │CSI                          │Enabled                      │
755       ├─────────────────────────────┼─────────────────────────────┤
756       │Interface Stability          │Standard                     │
757       └─────────────────────────────┴─────────────────────────────┘
758

SEE ALSO

760       Intro(1), ctags(1), ed(1), edit(1), ex(1),  attributes(5),  environ(5),
761       largefile(5), standards(5)
762
763
764       Solaris Advanced User's Guide
765

AUTHOR

767       vi and ex were developed by The University of California, Berkeley Cal‐
768       ifornia, Computer Science Division, Department of Electrical  Engineer‐
769       ing and Computer Science.
770

NOTES

772       Two options, although they continue to be supported, have been replaced
773       in the documentation by options that follow the Command Syntax Standard
774       (see  Intro(1)). An -r option that is not followed with an option-argu‐
775       ment has been replaced by -L and +command has been replaced by -c  com‐
776       mand.
777
778
779       The  message  file  too  large to recover with -r option, which is seen
780       when a file is loaded, indicates that the file can be edited and  saved
781       successfully,  but if the editing session is lost, recovery of the file
782       with the -r option is not possible.
783
784
785       The editing environment defaults to certain configuration options. When
786       an  editing  session is initiated, vi attempts to read the EXINIT envi‐
787       ronment variable. If it exists, the editor uses the values  defined  in
788       EXINIT;   otherwise   the  values  set  in  $HOME/.exrc  are  used.  If
789       $HOME/.exrc does not exist, the default values are used.
790
791
792       To use a copy of .exrc located in  the  current  directory  other  than
793       $HOME,  set  the  exrc  option in EXINIT or $HOME/.exrc. Options set in
794       EXINIT can be turned off in a local .exrc only if exrc is set in EXINIT
795       or  $HOME/.exrc.  In  order  to  be used, .exrc in $HOME or the current
796       directory must fulfill these conditions:
797
798           o      It must exist.
799
800           o      It must be owned by the same userid as the  real  userid  of
801                  the process, or the process has appropriate privileges.
802
803           o      It is not writable by anyone other than the owner.
804
805
806       Tampering    with    entries    in    /usr/share/lib/terminfo/?/*    or
807       /usr/share/lib/terminfo/?/*  (for  example,  changing  or  removing  an
808       entry)  can  affect  programs  such  as  vi that expect the entry to be
809       present and correct. In particular, removing the  "dumb"  terminal  can
810       cause unexpected problems.
811
812
813       Software tabs using ^T work only immediately after the autoindent.
814
815
816       Left  and  right  shifts  on  intelligent  terminals do not make use of
817       insert and delete character operations in the terminal.
818
819
820       Loading an alternate malloc() library using  the  environment  variable
821       LD_PRELOAD can cause problems for /usr/bin/vi.
822
823
824       The vi utility currently has the following limitations:
825
826           1.     Lines, including the trailing NEWLINE character, can contain
827                  no more than 4096 bytes.
828
829                  If a longer line is found, Line too long is displayed in the
830                  status line.
831
832           2.     The  editor's  temporary  work  file  can  be no larger than
833                  128Mb.
834
835                  If a larger temporary file is needed, Tmp file too large  is
836                  displayed in the status line.
837
838
839
840SunOS 5.11                        16 May 2007                            vi(1)
Impressum