Lines Matching refs:the
1 Section 26: Index to the rest of the tutorial
3 The remainder of the tutorial can be perused at your leisure. Simply find the
4 topic of interest in the following list, and {/Section xx:/^M} to get to the
5 appropriate section. (Remember that ^M means the return key)
7 The material in the following sections is not necessarily in a bottom up
10 several {n} to do a keyword search of the file for more details on that item.
12 can therefore be found rather easily. To see where, say, the X command is
13 used try {/{X}/^M}. Subsequent {n} will show you other places the command was
14 used. We have tried to maintain the convention of placing the command letter
15 surrounded by curly-braces on the section line where that command is
19 own experimentation with commands without too much hand-holding on the part of
20 the tutorial. Experimentation is the best way to learn the effects of the
25 (Sections 1 through 25 are located in the file vi.beginner.)
52 26 Index to the rest of the tutorial ******** YOU ARE HERE *******
53 27 discussion of repeat counts and the repeat command: {.}
56 30 updating the screen: {^R}
74 42 vi's relationship with the ex editor: {:}
119 Section 27: repetition counts and the repeat command {.}
123 us to line 22 of the file. For almost all of the commands, one can survive by
124 thinking of these leading numbers as a 'repeat count' specifying that the
127 Other commands use the repeat count slightly differently, like the {G} command
132 {3^D} means scroll down in the file three lines. Subsequent {^D} OR {^U} will
135 {3z^M} says put line three of the file at the top of the screen, while {3z.}
136 says put line three as close to the middle of the screen as possible.
138 {50|} moves the cursor to column fifty in the current line.
144 Position the cursor on some text and try {3r.}. This replaces three characters
145 with '...'. However, {3s.....^[} is the same as {3xi.....^[}.
149 A very useful instance of a repetition count is one given to the '.' command,
150 which repeats the last 'change' command. If you {dw} and then {3.}, you will
157 work: indeed, if you are at the end of your file and try {3^B} sufficiently
158 often, the editor will hang you in an infinite loop. Please don't try it:
163 Position the cursor on line 13 below:
167 Note that {fv} moves the cursor on/over the 'v' in 'seven'. Do a {0} to return
168 to the beginning of the line and try a {tv}. The cursor is now on/over the
169 first 'e' in 'seven'. The {f} command finds the next occurrence of the
170 specified letter and moves the cursor to it. The {t} command finds the
171 specified letter and moves the cursor to the character immediately preceding
174 Now try {60|}: the cursor is now on the 'o' in 'brought', which is the
175 sixtieth character on the line.
179 Due to their complexity we have delayed discussion of two of the most powerful
181 explanation than was deemed appropriate for the first half of the tutorial.
185 #BUFFERS), the {d} or {c}, and the object or range description. We will not
187 specifications. Examples speak louder than words: position the cursor at the
193 position the cursor on the 'b' of 'bear'. Now, type {cwbare^[}
194 and observe the results. The {cw} specifies that the change command {c} is to
195 operate on a word object. More accurately, it specifies that the range of the
196 change command includes the next word.
198 Position the cursor on the period in Line 14. (one way is to use {f.})
199 Now, type {cbbeast^[}. This specifies the range of the change command to be the
200 previous word (the 'b' reminiscent of the {b} command). If we had wished to
201 delete the word rather than change it, we would have used the {d} operator,
202 rather than the {c} operator.
204 Position the cursor at the beginning of the line with {0}. Type
205 {d/look/^M}. The search string specified the range of the delete.
206 Everything UP TO the word 'looking' was deleted from the line.
208 In general, almost any command that would move the cursor will specify a range
210 {cc} is entered: they refer to the whole line. Following is a summary of the
211 suffixes (suffices? suffici?) and the ranges they specify:
215 ^[ cancels the command
216 w the word to the right of the cursor
218 b the word to the left of the cursor
223 $ to the end of the line
224 ^ to the beginning of the line
225 / .. / up to, but not including, the string
226 ? .. ? back to and including the string
227 fc up to and including the occurrence of c
228 Fc back to and including the occurrence of c
229 tc up to but not including the occurrence of c
230 Tc back to but not including the occurrence of c
234 ( the previous sentence if you are at the beginning of
235 the current sentence, or the current sentence up to where
236 you are if you are not at the beginning of the current
237 sentence. Here, 'sentence' refers to the intuitive
240 ) the rest of the current sentence
246 H the first line on the screen
247 M the middle line on the screen
248 L the last line on the screen
249 3L through the third line from the bottom of the screen
255 This list is not exhaustive, but it should be sufficient to get the idea
256 across: after the {c} or {d} operator, you can specify a range with another
257 move-the-cursor command, and that is the region of text over which the command
260 Section 30: updating the screen {^R}
262 Vi tries to be very intelligent about the type of terminal you are working on
263 and tries to use the in-terminal computing power (if any) of your terminal.
264 Also if the terminal is running at a low baud rate (say 1200 or below), vi sets
267 rate) not all 24 lines of the screen would be used by vi. In addition, there
268 is a large portion of the editor keeping track of what your screen currently
270 then compares the two, and updates only those portions of the screen that have
274 deleting lines or changing large portions of text may leave some lines on the
277 meaning that this line of the screen does not correspond to any line in your
278 file. It would cost more to update the line than to leave it blank for the
279 moment. If you would like to see your screen fully up-to-date with the
283 {u} to get the lines back.
285 Here is as good a place as any to mention that if the editor is displaying the
286 end of your file, there may be lines on the screen that look like:
289 simply indicate the end of the file.
293 Vi gives you the ability to store text away in "buffers". This feature is very
295 five buffers available in vi. There is the "unnamed" buffer that is used by all
296 commands that delete text, including the change operator {c}, the substitute
297 and replace commands {s} and {r}, as well as the delete operator {d} and delete
299 are used. However, the undo command {u} has no effect on the unnamed buffer.
301 There are twenty-six buffers named 'a' through 'z' which are available for the
302 user. If the name of the buffer is capitalized, then the buffer is not
303 overwritten but appended to. For example, the command {"qdd} will delete one
304 line and store that line in the 'q' buffer, destroying the previous contents of
305 the buffer. However, {"Qdd} will delete one line of text and append that line
306 to the current contents of the 'q' buffer.
308 Finally, there are nine buffers named '1' through '9' in which the last nine
309 deletes are stored. Buffer 1 is the default buffer for the modify commands and
310 is sometimes called the unnamed buffer.
312 To reference a specific buffer, use the double-quote command {"} followed by
313 the name of the buffer. The next two sections show how buffers can be used to
323 Type {dd}. Line 15 has disappeared and been replaced with the empty line (one
324 with the single character @ on it) or (again depending on your terminal) Line
326 {u} but that would simply return it to its original location. Obviously, the
328 simply done with the put command {p}, which you should type now. What has
329 happened is that {dd} put Line 15 into the unnamed buffer, and the {p} command
330 retrieved the line from the unnamed buffer.
332 Now type {u} and observe that Line 15 disappears again (the put was undone
333 without affecting the unnamed buffer). Type {P} and see that the capital {P}
334 puts the line BEFORE the cursor.
338 Also in Line 15 note that the words 'tree' and 'poem' are reversed. Using the
340 (note the use of the reverse quote).
342 The put commands {p} and {P} do not affect the contents of the buffer.
343 Therefore, multiple {p} or {P} will put multiple copies of the unnamed buffer
349 Position the cursor on Line 17 and {z^M}:
353 Our task is to alphabetize the words on line 17. With the named buffers (and a
358 stores each of the words in the named buffer corresponding to the first letter
359 of each of the words ('interest' goes in buffer "i, 'apple' goes in buffer "a,
360 etc.). Now to put the words in order type:
364 Notice that, because 'farmer' was at the end of the line, {dw} did not include
371 You do not have to delete the text in order to put it into a buffer. If all
372 you wish to do is to copy the text somewhere else, don't use {d}, rather use
373 the yank commands {y} or {Y}. {y} is like {d} and {c} - an operator rather
375 specification. Therefore, instead of {dw}{P} to load the unnamed buffer with a
376 word without deleting the word, use {yw} (yank a word).
379 equivalent to {yy} (remember that operators doubled means the current line),
382 If the text you yank or modify forms a part of a line, or is an object such as
383 a sentence which partially spans more than one line, then when you put the text
384 back, it will be placed after the cursor (or before if you use {P}). If the
386 changing the current line. In this case, the put acts much like the {o} or {O}
390 However, the unnamed buffer is lost when you change files, so to move text from
395 Vi also keeps track of the last nine deletes, whether you ask for it or not.
397 accidentally deleted or modified. Position the cursor on line 18 following,
412 The command {"1p} will retrieve the last delete. Furthermore, when the
413 numbered buffers are used, the repeat-command command {.} will increment the
415 of the deleted lines, albeit in reverse order. If you would like to review the
416 last nine deletes without affecting the buffers or your file, do an undo {u}
421 will show you all the buffers and leave them and your file intact.
423 If you had cheated above and deleted the nine lines with {9dd}, all nine lines
424 would have been stored in both the unnamed buffer and in buffer number 1.
425 (Obviously, buffer number 1 IS the unnamed buffer and is just the default
426 buffer for the modify commands.)
430 We've already looked at writing out the file you are editing with the
437 Instead of entering vi and editing the first file, exiting, entering vi and
438 editing the second, etc., vi will allow you to specify ALL files that you wish
439 to edit on the invocation line. Therefore, if you wanted to edit file1 and
445 out {:w^M} and then type {:n^M} to get the next file on the list. On large
452 will bring in the next file.
454 If you have made changes to the first file, but decide to discard these changes
455 and proceed to the next file, {:n!^M} forces the editor to discard the current
456 contents of the editor.
459 will replace the current list of files (if any).
461 You can see the current list of files being edited with {:args^M}.
465 Typing {:r fname^M} will read the contents of file fname into the editor and
466 put the contents AFTER the cursor line.
468 Typing {:r !cmd^M} will read the output of the command cmd and place that
469 output after the cursor line.
473 To edit another file not mentioned on the invocation line, type {:e filename^M}
474 or {:vi filename^M}. If you wish to discard the changes to the current file,
475 use the exclamation point after the command, e.g. {:e! filename^M}.
479 Occasionally, it is useful to interrupt the current editing session to perform
480 a UNIX task. However, there is no need to write the current file out, exit
481 the editor, perform the task, and then reinvoke the editor on the same file.
484 At this point, the editor is put to sleep and will be reawakened when you log
485 out of the shell.
488 is the command that you wish to run. The output of the command will come to
489 the terminal as normal, and will not be made part of your file. The message
490 "[Hit return to continue]" will be displayed by vi after the command is
491 finished. Hitting return will then repaint the screen. Typing another
495 tricky, but hang in there. When you logged into UNIX, the first program you
497 over' the operating system protecting you from it, sort of like a considerate
498 porcupine). When you got your first prompt on the terminal (probably a '%'
499 character) this was the shell telling you to type your first command. When
500 you typed {vi filename} for some file, the shell did not go away, it just went
501 to sleep. The shell is now the parent of vi. When you type {^Z} the editor
502 goes to sleep, the shell wakes up and says "you rang?" in the form of another
503 prompt (probably '%'). At this point you are talking to the shell again and
505 only thing you can't do is log out: you will get the message "There are
508 When your business with the shell is done, type {fg} for 'foreground' and the
509 last process which you ^Z'd out of will be reawakened and the shell will go
510 back to sleep. I will refer you to the documentation for the Berkeley shell
517 the cursor on the section line (e.g. {/^Section 34.5:/^M}) and {z^M}. Now type
518 {^G} to find out the line number (it will be something like "line 513"). Now
519 {/^Section 34.6:/-1^M} to find the last line of this section, and {^G} to find
522 {:510,542w sepfile^M}. If sepfile already exists, you will have to use the
526 {:!cat sepfile^M} will display the file just written, and it should be the
529 There is an alternate method of determining the line numbers for the write.
530 {:set number^M} will repaint the screen with each line numbered. When the file
531 is written and the numbers no longer needed, {:set nonumber^M} will remove the
532 numbers, and {^R} will adjust the screen.
535 mark the beginning and ending lines. Suppose we had used {ma} to mark the
536 first line of the section and {mb} to mark the last. Then the command
537 {:'a,'bw sepfile^M} will write the section into "sepfile". In general,
538 you can replace a line number with the 'name' of a marked line (a single-quote
539 followed by the letter used to mark the line)
545 count, {!}, and a range specifier. Once the {!} operator is entered in its
546 entirety, a prompt will be given at the bottom of the screen for a UNIX
547 command. The text specified by the {!} operator is then deleted and
548 passed/filtered/piped to the UNIX command you type. The output of the UNIX
549 command is then placed in your file. For example, place the cursor at the
550 beginning of the following line and {z^M}:
553 ********* marks the bottom of the output from the ls command **********
555 Now type {!!csh^M}. The line will be replaced with the output from the ls
560 development. Of major concern was the formatting of sections of the tutorial
561 to fit on a single screen, particularly the first few sections. What was
567 'page'; meaning that there may be many blank lines at the end of a formatted
569 the output from nroff. Below are the two files used for this purpose: I refer
571 Position the cursor on the next line and {z^M}.
585 Determine the line numbers of the two lines of file f. They should be
587 under constant revision and the line numbers may change inadvertently. Then
588 {:574,575w f^M}. Do the same for the lines of file form.mac. They will be
594 clean it up dramatically. Position the cursor at the beginning
595 of this paragraph and type the following sequence of
598 of curly braces since the command itself contains a curly brace - we
599 will use square brackets for the nonce): [!}f^M].
602 specified that the paragraph (all text between the cursor and the first blank
603 line) will be removed from the edit file and piped to a UNIX program called
605 nroff, pipes its output to awk to remove blank lines, and the output from awk
606 is then read back into our file in the place of the old, ratty paragraph. The
608 to our taste (the right margin is not justified, the line is 79 characters
610 avoid conflict: note that in this file, the {^G} you see there is vi's display
611 of the control-G character, and not the two separate characters ^ up-arrow and
614 This example was created before the existence of the fmt program. I now type
615 [!}fmt^M] to get the same effect much faster. Actually, I don't type those
622 of the editor. This section assumes that the magic option is on. To make
625 By "magic pattern" we mean a general description of a piece of text that the
633 them on the first pass. Try typing {/c.rd/^M} followed by several {n} and
634 observe the effect.
638 When '.' is used in a search string, it has the effect of matching any single
641 The character '^' (up-arrow) used at the beginning of a search string means
642 the beginning of the line. {/^Line 27/^M} will find the example line above,
643 while {/Line 27/^M} will find an occurrence of this string anywhere in the
646 Similarly, {/ the$/^M} will find all occurrences of the word 'the' occurring
647 at the end of a line. There are several of them in this file.
649 Note that {:set nomagic^M} will turn off the special meaning of these magic
650 characters EXCEPT for '^' and '$' which retain their special meanings at the
651 beginning and end of a search string. Within the search string they hold no
652 special meaning. Try {/\/ the$\//^M} and note that the dollar-sign is not the
653 last character in the search string. Let the dollar-sign be the last
654 character in the search string, as in {/\/ the$/^M} and observe the result.
656 Observe the result of {/back.*file/^M}. This command, followed by sufficient
657 {n}, will show you all lines in the file that contain both the words 'back'
658 and 'file' on the same line. The '*' magic character specifies that the
659 previous regular expression (the '.' in our example) is to be repeatedly
660 matched zero or more times. In our example we specified that the words 'back'
661 and 'file' must appear on the same line (they may be parts of words such as
666 using the magic sequences '\<' or '\>'. E.g. {/\<back\>.*\<file\>/^M}. The
667 sequence '\<' specifies that this point of the search string must match the
668 beginning of a word, while '\>' specifies a match at the end of a word. By
675 exactly ONE character. The character matched will be one of the characters
676 enclosed in the square brackets. The characters may be specified individually
678 That is, [az] will match the letter 'a' OR the letter 'z', while [a-z] will
679 match any of the lower case letters from 'a' through 'z'. If you would like to
680 match either an 'a', a '-', or a 'z', then the '-' must be escaped: [a\-z] will
681 match ONE of the three characters 'a', '-', or 'z'.
685 uncapitalized letter by applying a special meaning to the '^' character in
686 square brackets: {/\<[^a-z][a-z]*\>/^M}. When '^' is the first character of a
690 To find all variable names (the first character is alphabetic, the remaining
693 In summary, here are the primitives for building regular expressions:
698 \< matches the beginning of a word
699 \> matches the end of a word
702 [x-y] matches any character in the ASCII range between x and y
703 * matches any number (including zero) of the preceding pattern
707 The straightforward colon-substitute command looks like the substitute
709 superstructure on the line-oriented editor ex and the colon commands are
713 The colon-substitute command looks like: {:s/ .. / .. /^M} and will find the
714 pattern specified after the first slash (this is called the search pattern),
715 and replace it with the pattern specified after the second slash (called,
716 obviously enough, the replacement pattern). E.g. position the cursor on line
721 The {u} and {U} commands work for {:s}. The first pattern (the search pattern)
722 may be a regular expression just as for the search command (after all, it IS a
723 search, albeit limited to the current line). Do an {u} on the above line, and
724 try the following substitute, which will do almost the same thing:
727 NOT followed by a blank: the search therefore ignores the 's'es in 'This' and
728 'is'. However, the character matched by {[^ ]} must appear in the replacement
732 in the search string into the replacement string. Line 29 below is a copy of
737 In general, you can nest parts of the search pattern in \( .. \) and refer to
738 it in the replacement pattern as \n, where n is a digit. The problem outlined
739 in the previous paragraph is solved with {:s/s\([^ ]\)/x\1/^M}: try it. Here
740 \1 refers to the first pattern grouping \( .. \) in the search string.
744 lines. (See the next section for a particularly comprehensive example.)
746 If the entire character sequence matched by the search pattern is needed in
747 the replacement pattern, then the unescaped character '&' can be used. On
748 Line 29 above, try {:s/an e.ample/not &/^M}. If another line is to have the
749 word 'not' prepended to a pattern, then '~' can save you from re-typing the
750 replacement pattern. E.g. {:s/some pattern/~/^M} after the previous example
753 One other useful replacement pattern allows you to change the case of
754 individual letters. The sequences {\u} and {\l} cause the immediately
755 following character in the replacement to be converted to upper- or lower-case,
757 such conversion on, either until {\E} or {\e} is encountered, or until the end
758 of the replacement pattern.
760 For example, position the cursor on a line: pick a line, any line. Type
761 {:s/.*/\U&/^M} and observe the result. You can undo it with {u}.
764 However, only the first pattern is substituted. If you would like ALL
765 patterns matched on the line to be substituted, append a 'g' after the
767 on the line of 123 with 456.
771 Ex (available through the colon command in vi) offers several methods for
772 specifying the lines on which a set of commands will act. For example, if you
776 what if you would like to make changes to just those lines? Then the
783 The lines above contain a typing error that the author of this tutorial tends
784 to make every time he attempts to type the word 'test'. To change all of these
785 'text's into 'test's, try the following:
786 {:/^Line 30/,/^Line 32/s/text/test/^M}. This finds the beginning and end of
787 the portion of text to be changed, and limits the substitution to each of the
788 lines in that range. The {u} command applies to ALL of the substitutions as
798 The above three lines have the second word out of order. The following command
801 consider reading the following section to understand it before trying the
802 experiment. Don't worry about messing up the rest of the file, though: the
807 There are several things to note about this command string. First of all, the
808 range of the substitute was limited by the address specification {/^Line
809 33/,/^Line 35/^M}. It might have been simpler to do {:set number^M} to see the
810 line numbers directly, and then, in place of the two searches, typed
811 the line numbers, e.g. {1396,1398}. Or to mark the lines with {ma} and {mb}
814 Then follows the substitute pattern itself. To make it easier to understand
815 what the substitute is doing, the command is duplicated below with the various
823 In overview, the substitute looks for a particular pattern made up of
825 by stating what they are NOT. Pattern \1 is the sequence of characters that
826 are NOT colons: in the search string, {[^:]} will match exactly one character
827 that is not a colon, while appending the asterisk {[^:]*} specifies that the
829 {\([^:]*\)} then gives the pattern its name, in this case \1. Outside of the
830 specification of \1 comes {: }, specifying that the next two characters must be
834 not blanks. Pattern \4 matches up to the period at the end of the line.
836 The replacement pattern then consists of specifying the new order of the
839 This is a particularly complicated example, perhaps the most complicated
841 tedious and error prone. For large files, however, it may be the most
842 efficient way to make the desired modifications.
844 (The reader is advised to look at the documentation for awk. This tool is very
850 certain patterns; e.g. for every line that has the string 'NPS' on it,
855 The general format of the command is {:g/(pattern)/cmds^M} and it
856 works in the following way: all lines that match the pattern
857 following the {:g} are 'tagged' in a special way. Then each of these
858 lines have the commands following the pattern executed over them.
869 tagged by the {:g}. Type {:g/^Line.*ABC/p^M} to verify this. Second, there
870 are two substitutes on the same line separated by '|'. In general, any colon
872 all three lines, even though the first stubstitute works on only two of the
873 lines (36 and 38). Fourth, the second substitute works on only two lines (36
874 and 37) and those are the two lines printed by the trailing 'p'.
876 The {:v} command works similarly to the {:g} command, except that the sense of
877 the test for 'tagging' the lines is reversed: all lines NOT matching the search
878 pattern are tagged and operated on by the commands.
881 substitutions to split two lines. For example, the command
883 separate line. (Note that we have to 'escape' the '.', because '.' by itself
885 period followed by 2 spaces, and inserts a carriage return after the period.)
887 Caveat: In some of the documentation for ex and vi you may find the
888 comment to the effect that {\^M} can be used between commands following
890 crashed the editor trying.
896 long as the command string does not contain any curly braces itself.
897 However, the curly braces are legitimate commands in vi. Therefore, for
899 sequence with SQUARE braces, as on the previous Section line.)
901 In working with a document, particularly if using the text formatting
904 the beginning of the previous and next sentences, respectively. Thus
905 the command {d)} will delete the rest of the current sentence; likewise
906 {d(} will delete the previous sentence if you are at the beginning of
907 the current sentence, or, if you are not at the beginning of a sentence,
908 it will delete the current sentence from the beginning
912 by either the end of a line, or by two spaces. Any number of closing
913 ')', ']', '"', and ''' characters may appear after the '.', '!', or '?'
914 before the spaces or end of line. Therefore, the {(} and {)} commands
915 would recognize only one sentence in the following line, but two
916 sentences on the second following line.
919 Line 40: This is two sentences. Because it has two spaces after the '.'.
921 The operations [{] and [}] move over paragraphs and the operations {[[}
925 paragraph macros. A section begins after each line with a form-feed ^L in the
928 to make the formatting specifications easier, or more to your taste. These
929 macros are invoked by beginning a line with a period followed by the one or two
931 if it doesn't recognize your particular macro you can use the {:set paragraphs}
937 during input mode. These are summarized in the following table.
939 ^H deletes the last input character
940 ^W deletes the last input word
942 for some it is ^H, for others it is the DELETE key, and for
944 (kill) deletes the input on this line; each terminal can define its
951 ^? the delete key; interrupts an insertion, terminating it
953 ^M the return key; starts a new line.
954 ^D backtabs over the indentation set by the autoindent option
955 0^D backtabs over all indentation back to the beginning of the line
956 ^^D (up-arrow followed by control-d)same as 0^D, except the indentation
957 will be restored at the beginning of the next line.
958 ^V quotes the next non-printing character into the file
961 must precede it with a \, just as you would do at the normal system command
962 level. A more general way of typing non-printing characters into the file is
963 to precede them with a ^V. The ^V echoes as a ^ character on which the cursor
964 rests. This indicates that the editor expects you to type a control character
965 and it will be inserted into the file at that point. There are a few
966 exceptions to note. The implementation of the editor does not allow the null
967 character ^@ to appear in files. Also the linefeed character ^J is used by the
968 editor to separate lines in the file, so it cannot appear in the middle of a
969 line. (Trying to insert a ^M into a file, or putting it in the replacement
970 part of a substitution string will result in the matched line being split in
972 insert any other character, however, if you wait for the editor to echo the ^
973 before you type the character. In fact, the editor will treat a following
974 letter as a request for the corresponding control character. This is the only
975 way to type ^S or ^Q, since the system normally uses them to suspend and resume
976 output and never gives them to the editor to process.
978 If you are using the autoindent option you can backtab over the indent which it
979 supplies by typing a ^D. This backs up to the boundary specified by the
980 shiftwidth option. This only works immediately after the supplied autoindent.
982 When you are using the autoindent option you may wish to place a label at the
984 then ^D. The editor will move the cursor to the left margin for one line, and
985 restore the previous indent on the next. You can also type a 0 followed
987 on the next line.
991 Below is a non-exhaustive list of commands that can follow the operators
992 to affect the range over which the operators will work. However, note
993 that the operators {<}, {>}, {!}, and {=} do not operate on any object
994 less than a line. Try {!w} and you will get a beep. To get the
995 operator to work on just the current line, double it. E.g. {<<}.
999 ^[ cancels the command
1000 w the word to the right of the cursor
1002 b the word to the left of the cursor
1007 $ to the end of the line
1008 ^ to the beginning of the line
1009 / .. / up to, but not including, the string
1010 ? .. ? back to and including the string
1011 fc up to and including the occurrence of c
1012 Fc back to and including the occurrence of c
1013 tc up to but not including the occurrence of c
1014 Tc back to but not including the occurrence of c
1018 ( the previous sentence if you are at the beginning of
1019 the current sentence, or the current sentence up to where
1020 you are if you are not at the beginning of the current
1021 sentence. Here, 'sentence' refers to the intuitive
1024 ) the rest of the current sentence
1030 H the first line on the screen
1031 M the middle line on the screen
1032 L the last line on the screen
1033 3L through the third line from the bottom of the screen
1039 This list is not exhaustive, but it should be sufficient to get the idea
1040 across: after the operator, you can specify a range with a move-the-cursor
1041 command, and that is the region of text over which the operator will be
1047 over and over. Vi gives you the ability to specify an abbreviation for
1048 a long string such that typing the abbreviation will automatically
1049 expand into the longer phrase.
1053 {iThis is to show off the nps's UNIX editor.^M^[}
1055 Section 42: vi's relationship with the ex editor: {:}
1057 Vi is actually one mode of editing within the editor ex. When you are
1058 running vi you can escape to the line oriented editor of ex by giving
1059 the command {Q}. All of the colon-commands which were introduced above
1064 will get a diagnostic and will be left in the command mode of ex. You can
1065 then save your work and quit if you wish by giving the command {x} after
1066 the colon prompt of ex. Or you can reenter vi (if you are brave) by
1067 giving ex the command {vi}.
1071 (The author has not checked the following documentation for accuracy. It is
1072 abstracted from the Introduction to Vi Editing document.)
1075 which can move off the bottom line, you can still use the command set of vi,
1076 but in a different mode. When you give the vi command to UNIX, the editor will
1077 tell you that it is using open mode. This name comes from the open command in
1078 ex, which is used to get into the same mode.
1080 The only difference between visual mode (normal vi) and open mode is the way in
1081 which the text is displayed.
1083 In open mode the editor uses a single line window into the file, and moving
1084 backward and forward in the file causes new lines to be displayed, always below
1085 the current line. Two commands of vi work differently in open: {z} and {^R}.
1087 around the current line and then returns you to the current line.
1089 If you are on a hardcopy terminal, the {^R} command will retype the current
1090 line. On such terminals, the editor normally uses two lines to represent the
1091 current line. The first line is a copy of the line as you started to edit it,
1092 and you work on the line below this line. When you delete characters, the
1093 editor types a number of \'s to show you the characters which are deleted. The
1094 editor also reprints the current line soon after such changes so that you can
1095 see what the line looks like again.
1098 support vi in the full screen mode. You can do this by entering ex and using
1105 on the first pass through this document. My advice is to glance through them,
1106 noting the ones that look interesting, ignoring the ones you don't understand,
1110 the default values for the editor, place a {setenv EXINIT} command in your
1112 placed in it a file that is executed each time you log in. If one of the
1113 commands in this file sets the environment variable EXINIT to a string of vi
1116 but prefer every four columns, and that you wish the editor to insert linefeeds
1118 autoindentation, then include the following line in your .login file:
1126 Each time you bring up vi, this command will be executed and the options set.
1128 There are forty options in the vi/ex editor that the user can set for his/her
1130 below. The section line will show the full spelling of the option name, the
1131 abbreviation, and the default value of the option. The text itself
1132 comes from the ex reference manual and is not the epitome of clarity.
1136 Can be used to ease the preparation of structured program text. At the
1139 visual mode, ex looks at the line being appended after, the first line changed
1140 or the line inserted before and calculates the amount of white space at the
1141 start of the line. It then aligns the cursor at the level of indentation so
1144 If the user then types lines of text in, they will continue to be justified at
1145 the displayed indenting level. If more white space is typed at the beginning
1146 of a line, the following line will start aligned with the first non-white
1147 character of the previous line. To back the cursor up to the preceding tab
1149 of the shiftwidth option. You cannot backspace over the indent, except by
1151 turns into a completely blank line (the white space provided for the autoindent
1153 an up-arrow `^' and immediately followed by a {^D}. This causes the input to
1154 be repositioned at the beginning of the line, but retaining the previous indent
1155 for the next line. Similarly, a `0' followed by a {^D} repositions at the
1156 beginning but without retaining the previous indent. Autoindent doesn't happen
1157 in global commands or when the input is not a terminal.
1161 Causes the current line to be printed after each delete, copy, join, move,
1162 substitute, t, undo or shift command. This has the same effect as supplying a
1164 only applies to the last of many commands on a line.
1168 Causes the contents of the buffer to be written to the current file if you have
1171 the edit and ex commands do not autowrite. In each case, there is an
1172 equivalent way of switching when autowrite is set to avoid the autowrite
1179 discarded from the input. A complaint is registered the first time a backspace
1184 Specifies the directory in which ex places its buffer file. If this directory
1185 in not writable, then the editor will exit abruptly when it fails to be able to
1190 Causes the presence or absence of g and c suffixes on substitute commands to be
1191 remembered, and to be toggled by repeating the suffices. The suffix r makes
1192 the substitution be as in the {~} command, instead of like {&}.
1199 visual modes on errors is not suppressed by setting noeb. If possible the
1200 editor always places the error message in a standout mode of the terminal (such
1201 as inverse video) instead of ringing the bell.
1205 Gives the boundaries on which terminal hardware tabs are set (or on which the
1210 All upper case characters in the text are mapped to lower case in regular
1217 Autoindent indents appropriately for lisp code, and the {(}, {)}, [{], [}],
1226 and end-of-lines with `$'. This is the same as in the ex command {list}.
1230 If nomagic is set, the number of regular expression metacharacters is greatly
1232 the metacharacters `~' and `&' of the replacement pattern are treated as normal
1233 characters. All the normal metacharacters may be made magic when nomagic is
1236 [Author's note: In other words, if magic is set a back-slant turns the magic
1237 off for the following character, and if nomagic is set a back-slant turns the
1238 magic ON for the following character. And, no, we are not playing Dungeons and
1239 Dragons, although I think the writers of these option notes must have played it
1240 all the time.]
1244 Causes write permission to be turned off to the terminal while you are in
1259 If {noopen}, the commands open and visual are not permitted. This is set for
1264 editors available under Berkeley UNIX that are in reality the same
1269 Throughput of text is expedited by setting the terminal to not do automatic
1278 Specifies the paragraphs for the [{] and [}] operations in open and visual.
1279 The pairs of characters in the option's value are the names of the nroff macros
1292 accident. You can set the option and writes will fail unless you use an `!'
1293 after the write. Commands such as {x}, {ZZ}, the autowrite option, and in
1295 invoke the editor with the -R flag.
1300 on a dumb terminal (e.g. during insertions in visual the characters to the
1301 right of the cursor position are refreshed as each input character is typed).
1302 Useful only at very high baud rates, and should be used only if the system is
1303 not heavily loaded: you will notice the performance degradation yourself.
1314 more than the specified number of lines will provide feedback as to the scope
1316 potentially more far reaching scope, the net change in the number of lines in
1317 the buffer is presented at the end of the command, subject to this same
1318 threshold. Thus notification is suppressed during a global command on the
1323 Determines the number of logical lines scrolled when a {^D} is received from a
1324 terminal in command mode, and determines the number of lines printed by a
1325 command mode z command (double the value of scroll).
1331 Specifies the section macros from nroff for the {[[} and {]]} operations in
1332 open and visual. The pairs of characters in the options's value are the names
1333 of the macros which start paragraphs.
1337 Gives the path name of the shell forked for the shell escape command `!', and
1338 by the shell command. The default is taken from SHELL in the environment, if
1341 [Editor's note: I would suggest that you place the following line in
1349 used by the shift commands. Should probably be the same value as the tabstop
1354 In open and visual mode, when a `)' or `}' is typed, if the matching `(' or `{'
1355 is on the screen, move the cursor to it for one second. Extremely useful with
1360 Affects the display algorithm used in visual mode, holding off display updating
1361 during input of new text to improve throughput when the terminal in use is both
1367 The editor expands tabs ^I to tabstop boundaries in the display.
1372 A value of zero (the default) means that all characters are significant.
1376 A path of files to be used as tag files for the tag command. A requested tag
1377 is searched for in the specified files, sequentially. By default files called
1378 tags are searched for in the current directory and in /usr/lib (a master file
1379 for the entire system).
1386 The terminal type of the output device.
1390 Shorter error diagnostics are produced for the experienced user.
1412 The number of lines in a text window in the visual command. The default is 8
1413 at slow speeds (600 baud or less), 16 at medium speed (1200 baud), and the full
1418 Searches using the regular expressions in addressing will wrap around past the
1419 end of the file.
1424 modes. The numeric value is the number of columns from the right edge of the
1431 Inhibit the checks normally made before write commands, allowing a write to any
1432 file which the system protection mechanism will allow.
1438 These are not true options but set the default size of the window for when the
1440 suitable for an EXINIT and make it easy to change the 8/16/full screen rule.
1444 Here are some editor limits that the user is likely to encounter:
1448 128 characters in the previous inserted and deleted text in open or
1453 250000 lines in the file (this is silently enforced).
1455 The visual implementation limits the number of macros defined with map to 32,
1456 and the total number of characters in macros to be less than 512.