.ifnot system .! VI.RNO - Installation and help for VI emulation in TPU .! Written by Gregg Wonderly 22-JUL-1987 .! .! RUNOFF operation instructions: .! .! $ @VIDOC.COM .! .! to create a document for printing. .! .! We set the layout so that running page numbers are on the bottom .! .lo 1,2 .st .! .! Initial right margin - sections should never set it higher than this. .! Set page size too. .ps 57,70 .rm 65 .! .! Header level setup .sthl 6,0,0,8,9,1,1,9,2 .dhl D,D,lu,d,ll,ll .! .! .flags bold .flags overstrike .! .c; .sk 2 .c;Guide for VI written in TPU .title Guide for VI written in TPU .sk 2 .c;Gregg Wonderly .c;Mathematics Department .c;Oklahoma State University .sk 1 .c;22-Jul-1987 .else system .NO FLAGS ALL .P0 .ap .NO NUMBER .NPA .LM1.RM70 .I-1 1 VI .s VI is a text editor written in TPU, for more background information, see "HELP VI Introduction". .s .endif system .! .ifnot system .pg .hl 1 ^*Table of contents\* .req "vi.rnt" .pg .send toc .ifnot global .hl 1 ^*Purpose of this document\* .send toc .endif global This document provides an overview of this particular emulation of the VI editor. It does not provide information on learning to use the VI editor. It is assumed that the reader knows how to use VI to a reasonable extent, and/or has access to a VI manual or quick reference guide. .send toc .ifnot global .hl 1 ^*Introduction to VI\* .send toc .endif global .! .else system .! .i-1 2 Introduction .s .endif system .! VI is an editor which was originally written by Bill Joy at the University of Berkeley in California. It was written to work on the UNIX (UNIX is a trademark of the American Telephone and Telegraph Corporation) operating system, and until now, has not been widely available on other operating systems. VI is an excellent editor, but its full potential can not be realized without a full understanding of the commands that are available. Currently, this help file does not describe all of the keystrokes that are defined. You should consult one of the many VI quick reference guides for that information. This version of VI should be close enough to the real version that the documentation of the additional features here, and a VI quick reference guide should suffice. .s VI is a mode oriented editor, and has two modes. One mode allows text entry by simply typing (called text entry mode), and the other allows text manipulation by using the typing keys (called command mode). This is a completely different approach to editing than used by most other text editors and word processors. However, it provides some incredible possibilities for speed because one does not have to look to find function keys to perform certain editing tasks. Also, many more commands can be placed within reach of your hands because all of the keys on the keyboard are available for use during command mode operations. .s .! .if system .i-1 2 Author .s This emulation of VI was written by .s .lm+5 Gregg Wonderly .br Mathematics Department .br Oklahoma State University .s Internet: gregg@nemo.math.okstate.edu .lm-5 .s .endif system .! .ifnot system .send toc .ifnot global .hl 1 ^*Extensions to VI\* .send toc .endif global .else system .i-1 2 Extensions .s .endif system This emulation of VI contains some extensions that were made possible by the existance of supporting primitives in TPU. A partial list of these extensions follows. .s .lm+5 Select regions are available and can be used to perform many operations such as deleting, yanking, changing, shifting, changing/inverting case, compiling TPU procedures, filling regions of text to fit within a specified range of columns and writing portions of buffers to files/devices. .s Multiple buffers are available as well as multiple windows to display the buffers in. This allows you to edit/view many files at once. .s You can force the editor to expand tabs as you type them, so that they are replaced by spaces in the text. .s You can control the use of TPU's typeahead recognition so that you see each screen update action while you type (with ":set [no]update"). .s The EX mode commands, 'show buffers' and 'show files', display information about existing buffers, and the current list of files to edit, respectively. .s The EX mode command, sh, has an alias called 'dcl', which is a little more indicative of the action taken. .s The EX mode command, buffer, allows you to create a new buffer that may not have a file associated with it. It also allows you to create a buffer by a specific name, and associate an arbitrary file with that buffer. .s The EX mode command, messages, allows you to map the TPU message buffer into the current window for viewing. .s The EX mode command, delbuf, allows you to delete a buffer according to its name. .s The EX mode command, prev, allows you to move back to the previously edited buffer that you used the 'next' command to leave. .s The EX mode command, tpu, allows you to execute arbitrary TPU statements from the editor. .lm-5 .ifnot system .send toc .ifnot global .hl 1 ^*Using an initialization file\* .send toc .endif global .else system .I-1 2 Initialization .s .endif system VI allows you to use a file to initialize the options and settings that you wish to use, automatically, each time the editor is envoked. Note that when you use VI in a subprocess, the initialization is done only when the subprocess is first created, and not on any subsequent attach operations. The file SYS$LOGIN:VI.INI can contain EX mode commands, one per line, that will be executed after the file(s) selected are loaded into buffers. Alternatively, the file may be located anywhere by defining the logical name, EXRC, to be the name of the file you wish to use for initialization (this name is similar, minus a leading '.', to that used under UNIX). Also, if you have only a single line of initialization, then the process logical, EXINIT (again a holdover from UNIX), can be defined to be the line of initialization, and it will be translated, and the resulting text executed. This is generally faster than processing the EXRC file. .! .ifnot system .send toc .ifnot global .hl 1 ^*Supported EX mode commands\* .send toc .endif global .else system .I-1 2 Ex_mode .s .endif system .! EX mode is entered by typing a ":" (or the DO key). From the ":" prompt, you can perform many different functions associated with changing the operation of the editor. EX mode also allows you to perform operations such as global search and replace, block deletion of text, and many other operations that are not easily described with a single keystroke. Below is a list of the commands that can be performed from EX mode. The term, l_spec, is a specification for a line of the current file, and takes the form of either a search pattern, as in: .lm +5 .s /foo/ or ?foo? .s .lm -5 an explict line number as in "5", or perhaps a relative line number as in ".+5" which means the current line, plus five lines. There are two other special characters, like ".", they are "$" which means the last line of the file, and "%" which means every line in the file. Any place that two l_specs are required to delimit a range of lines, a single "%" can be used to specify the entire file. Markers can also be used as l_specs. A single ' character should precede the letter corresponding to the mark. e.g. 'a,'b is the range of lines from mark 'a' to mark 'b'. Certain commands such as "w" act on the entire buffer by default, and do not require a range. If you specify a range of lines by separating two l_specs with a ",", the first specification must indicate a line that preceeds the second specification. If not, the message, "Bad range of lines!" will be displayed, and the command will be aborted. .if system .I-1 3 Abort_edit .else system .send toc .if global .hl 2 ^*Abort edit\* .send toc .endif global .endif system .s .LT :q{uit}[!] This command quits the editor. If "!" is not specified, and there are modified buffers, then you will be told so, and the command will be aborted. You must then either retype the command with a "!" (if you really want to ignore the modified buffers, and lose those changes), or you must write out the modified buffers. .EL .if system .I-1 3 Change_output_file .else system .send toc .ifnot global .hl 2 ^*Change output file\* .send toc .endif global .endif system .s .LT :file Changes the output file specification of the current buffer to the specified file. This will result in the buffer being written to the new file whenever a ":w", ":xit" or "ZZ" command is issued. Note that an unmodified buffer will still be un- modified after this has been done, so you must write it out explicitly, or modify it inorder to assure the a file by the indicated name is created .EL .if system .I-1 3 Compile_TPU .else system .send toc .ifnot global .hl 2 ^*Compile TPU\* .send toc .endif global .endif system .s .LT :[l_spec][,l_spec]tpu Compiles the indicated region, making the assumption, that the region contains TPU language code. An active select region can be used in place of the l_specs. .EL .if system .I-1 3 Copy_lines .else system .send toc .ifnot global .hl 2 ^*Copy lines\* .send toc .endif global .endif system .s .LT :l_spec_1,l_spec_2 c{opy} l_spec_3 The range of lines indicated by l_spec_1 and l_spec_2 are copied in their entirety, to the location after the line indicated by l_spec_3. .EL .if system .I-1 3 Create_buffers .else system .send toc .ifnot global .hl 2 ^*Create buffers\* .send toc .endif global .endif system .s .LT :b{uffer} [] [] This command maps the buffer named to the current window. If there is no buffer by the name given, then a new buffer will be created. If is given, the named file will be read into any newly created buffer. .EL .if system .I-1 3 Create_key_macro .else system .send toc .ifnot global .hl 2 ^*Create key macro\* .send toc .endif global .endif system .s .LT :map[!] Allows you to establish a mapping or macro for a single keystroke. If a "!" is specified then the mapping/macro is in effect during text entry mode, otherwise the mapping/macro is in effect during command mode. The next time that is typed in the affected mode, the string of keystokes specified will be substituted for the single key typed. ":map" without any parameters displays the current mappings. .EL .if system .I-1 3 Delete_buffers .else system .send toc .ifnot global .hl 2 ^*Delete buffers\* .send toc .endif global .endif system .s .LT :de{lbuf}[!] This command allows you to delete a buffer by name so that it is no longer in existance. This will destroy the contents of the buffer. If the buffer is modified you can specify the "!" to assure that the buffer is deleted. Otherwise when the buffer is modified you will be prompted to make sure that you wish to delete that buffer. An unmodifed buffer will be deleted without any prompting, whether or not a "!" is specified. Note that the current buffer can never be deleted unless there is more than one window on the screen. When this is the case, then the window(s) occupied by the buffer you wish to delete will be deleted from the screen. When a window containing the object buffer is occluded (hidden) during MAKE FULL SCREEN, then you will not be able to delete that buffer. .EL .if system .I-1 3 Delete_lines .else system .send toc .ifnot global .hl 2 ^*Delete lines\* .send toc .endif global .endif system .s .LT :[l_spec][,l_spec]d Delete the line(s) specified. If a range of lines is not specified, the current line is deleted. .EL .if system .I-1 3 Edit_new_file .else system .send toc .ifnot global .hl 2 ^*Edit new file\* .send toc .endif global .endif system .s .LT :e{dit} This command allows you to switch to a different file that you want to edit. File spec is first compared to the name of an existing buffer. If there is a buffer by that name, then it is mapped to the current window. If not, then the indicated file will be read into a new buffer, which will be mapped to the current window. .EL .if system .s .LT :vi This command is an alias for the e[dit] command. For more information see the description of that command. .EL .endif system .! .if system .I-1 3 Execute_command_file .else system .send toc .ifnot global .hl 2 ^*Execute command file\* .send toc .endif global .endif system .s .LT :so The specified file will be read, line by line, and each line will be interpreted as an EX mode command. .EL .if system .I-1 3 Fill_text_region .else system .send toc .ifnot global .hl 2 ^*Fill text region\* .send toc .endif global .endif system .s .LT :[l_spec][,l_spec]fill The indicated lines will be filled, wrapped, and joined so that they are as full as possible. The left and right margin values will determine how long the lines are, and where they start and stop. A select region may be used in place of the l_specs. .EL .if system .I-1 3 Global_Substitution .else system .send toc .ifnot global .hl 2 ^*Global Substitution\* .send toc .endif global .endif system .s .LT :[gv]/search_re/cmd whether or not the substitution is to If g is specified then cmd is performed on all lines containing search_re. If v is specified then cmd is performed on all lines NOT containing search_re. cmd is either 'd' to delete the selected lines, s/from_re/to_re/[g][c] to perform a substitution within the selected lines (see the substitute command elsewhere for a description of its operation), or 'p' to print the lines matched by the search_re and the particular mode, 'g' or 'v'. The lines selected will be placed into a buffer that is mapped onto the current window. You will be asked to hit return when the command has completed. .EL .if system .I-1 3 Goto_Line .else system .send toc .ifnot global .hl 2 ^*Goto Line\* .send toc .endif global .endif system .s .LT :l_spec[,l_spec] Goto the beginning of the line(s) specified. .EL .if system .I-1 3 Goto_tag_in_file .else system .send toc .ifnot global .hl 2 ^*Goto tag in file\* .send toc .endif global .endif system .s .LT :ta [tag] The tag specified, or if none, then the tag following the cursor is located in one of the files specified by the "tags" value. The associated file is loaded, or switched to, and the corresponding command executed. If the tag can not be located, then a diagnostic is issued. .EL .if system .I-1 3 Help .else system .send toc .ifnot global .hl 2 ^*Help\* .send toc .endif global .endif system .s .LT :help Gives you access to this document as well as other VMS help topics from within VI. .EL .if system .I-1 3 Invert_case .else system .send toc .ifnot global .hl 2 ^*Invert case\* .send toc .endif global .endif system .s .LT :[l_spec][,l_spec]in{vert} The case of all alphabetic characters in the indicated region will be inverted. A select range may be used in place of the l_specs .EL .if system .I-1 3 Learn_Key_Strokes .else system .send toc .ifnot global .hl 2 ^*Learn Key Strokes\* .send toc .endif global .endif system .s .LT :learn Initiates remembering of keystrokes. This allows a particular sequence of key strokes to be repeated at a later time by typing a single key. This facility is similar to that provided by the :map command. The difference being, that you must "know" the keys you want to type for the :map command. A learn sequence is remembered as you type the keys and the associated actions are carried out. When you are done typing a learn sequence, then you should use CTRL-R to bind that sequence to the desired key. Note that :set undomap also pertains to how learned sequence behave when undo is performed. .EL .if system .I-1 3 Lower_case .else system .send toc .ifnot global .hl 2 ^*Lower case\* .send toc .endif global .endif system .s .LT :[l_spec][,l_spec]lo{wer} The case of all alphabetic characters in the indicated region will be changed to lower case. A select region may be used instead of l_specs. .EL .if system .I-1 3 Message_buffer .else system .send toc .ifnot global .hl 2 ^*Message buffer\* .send toc .endif global .endif system .s .LT :me{ssages} This command simply maps the TPU messages buffer to the current window so that its contents may be viewed. You may use the ^~ (Ctrl-tilde) key- stroke to switch back to the previous buffer. .EL .if system .I-1 3 Move_lines .else system .send toc .ifnot global .hl 2 ^*Move lines\* .send toc .endif global .endif system .s .LT :l_spec_1,l_spec_2 m{ove} l_spec_3 The range of lines indicated by l_spec_1 and l_spec_2 are moved in their entirety, to the location after the line indicated by l_spec_3. .EL .if system .I-1 3 Next_file .else system .send toc .ifnot global .hl 2 ^*Next file\* .send toc .endif global .endif system .s .LT :n{ext} Moves the pointer in the list of files currently being edited to the next file. The buffer associated with that file will be mapped to the current window. .EL .if system .I-1 3 Perform_Macros .else system .send toc .ifnot global .hl 2 ^*Perform Macros\* .send toc .endif global .endif system .s .LT :@ Executes the first line of the indicated named buffers as command mode commands. .EL .if system .I-1 3 Previous_file .else system .send toc .ifnot global .hl 2 ^*Previous file\* .send toc .endif global .endif system .s .LT :pr{ev} Moves the pointer in the list of files currently being edited, to the previous file. The buffer associated with that file will be mapped to the current window. .EL .if system .I-1 3 Print_out_lines .else system .send toc .ifnot global .hl 2 ^*Print out lines\* .send toc .endif global .endif system .s .LT :[l_spec,l_spec]p Scrolls the current buffer through the range of lines indicated, in the current window. .EL .if system .I-1 3 Read_file_into_buffer .else system .send toc .ifnot global .hl 2 ^*Read file into buffer\* .send toc .endif global .endif system .s .LT :[l_spec]r{ead} Reads the contents of the specified file, and inserts it into the current buffer after the indicated line. If no line is specified, then the current line is used. .EL .if system .I-1 3 Rewind_file_list .else system .send toc .ifnot global .hl 2 ^*Rewind file list\* .send toc .endif global .endif system .s .LT :rew Will reset the pointer in the list of files being edit to the first one. The buffer associated with that file will be mapped to the current window. .EL .if system .I-1 3 Select_regions .else system .send toc .ifnot global .hl 2 ^*Select regions\* .send toc .endif global .endif system .s .LT :select Toggles the status of the select region that can be used in place of a range specified in some of the EX mode commands, as well as any of the, buffer altering, command mode editing commands. .EL .if system .I-1 3 Set_default_dir .else system .send toc .ifnot global .hl 2 ^*Set default dir\* .send toc .endif global .endif system .s .LT :cd Changes the default directory that that the editor process is running in. The new default directory is shown in the message window. .EL .S .LT :chdir Same as the cd command. .EL .if system .I-1 3 Set_options .else system .send toc .ifnot global .hl 2 ^*Set options\* .send toc .endif global .endif system .s .LT :set [no]option[=value] [...] Sets one or more options that dictate the behavior of the editor. These options are described in full later. If the option is boolean in nature as is "wrapscan", then you must either specify "wrapscan" or "nowrapscan". If the option is variable in nature, as is "scroll", then you should specify "option=value" as in "scroll=21". .EL .if system .I-1 3 Show_buffers .else system .send toc .ifnot global .hl 2 ^*Show buffers\* .send toc .endif global .endif system .s .LT :show buffers Displays the list of currently active buffers that you have created for editing files. .EL .if system .I-1 3 Show_current_version .else system .send toc .ifnot global .hl 2 ^*Showing Current Version\* .send toc .endif global .endif system .LT :version Places a message about the current version of VI into the status line. .EL .if system .I-1 3 Show_file_list .else system .send toc .ifnot global .hl 2 ^*Show file list\* .send toc .endif global .endif system .s .LT :show files Displays the list of one or more files that matched the file spec that you last gave as the parameter to a "vi" or "edit" command. This list of files is used by the ":next", ":prev" and ":rew" EX commands to allow you to cycle through a list of files in a logical sequence. You can change the line that the cursor is on to change which file :next and :prev display by using, ^D ^U, h, j, k, and l key strokes. .EL .if system .I-1 3 Show_tags .else system .send toc .ifnot global .hl 2 ^*Show Tags\* .send toc .endif global .endif system .s .LT :show tags Displays the contents of the buffer that is used to resolve "tag" references. This can be used to make sure that you are specifying the proper tags. .EL .if system .I-1 3 Spawn_command .else system .send toc .ifnot global .hl 2 ^*Spawn command\* .send toc .endif global .endif system .s .LT :! Spawns a subprocess to run the given DCL command in. You will be asked to "[Hit ENTER to continue]" before the screen is redrawn when the command finishes. .EL .if system .I-1 3 Spawn_subprocess .else system .send toc .ifnot global .hl 2 ^*Spawn subprocess\* .send toc .endif global .endif system .s .LT :sh (:dcl) Spawns a DCL subprocess that you can use to perform some DCL related task with, and then LOGOUT of. .EL .if system .I-1 3 Substitution .else system .send toc .ifnot global .hl 2 ^*Substitution\* .send toc .endif global .endif system .s .LT :l_spec[,l_spec]s/from_re/to_re/[g][c] Perform the indicated substitution on the indicated line(s) of text. Note that '&' is a single character alias for the last substitution made (not including line specs or options). The [g] option causes every occurence on a line to be replaced. By default, only the first is replaced. The [c] option will cause the editor to pause and highlight the text matching the from_re, before each substition. You are given the opportunity to say whether or not the substitution is to be performed. .EL .if system .I-1 3 Text_Abbreviations .else system .send toc .ifnot global .hl 2 ^*Text Abbreviations\* .send toc .endif global .endif system .s .LT :abbr Creates an abbreviation for the text given by . is a simple string of characters, e.g. ATT, and is a more complicated string as in, American Telephone and Tele- graph. ":abbr" by itself displays a list of the current abbreviations. :unabbr Removes a previously defined abbrev- iation that was defined with ":abbr". .EL .if system .I-1 3 Unmap_key_macros .else system .send toc .ifnot global .hl 2 ^*Unmap key macros\* .send toc .endif global .endif system .s .LT :unmap[!] Removes a previously established map. The "!" must be present if you wish to unmap a map that was made specifying the "!". .EL .if system .I-1 3 Upper_case .else system .send toc .ifnot global .hl 2 ^*Upper case\* .send toc .endif global .endif system .s .LT :[l_spec][,l_spec]upper The case of all alphabetic characters in the indicated region will be changed to upper case. A select region may be used in place of the l_specs. .EL .! .if system .I-1 3 Write_buffer .else system .send toc .ifnot global .hl 2 ^*Write buffer\* .send toc .endif global .endif system .s .LT :[l_spec][,l_spec]w{rite}[!] [] The indicated line(s) will be written to a file. The name of the file can either be specified, or will default to the current buffer. There are certain operations that are not permitted unless the "!" is typed following "w{rite}". If "!" is not present, you can NOT write all or portions of the buffer to a file that already exists, unless it is the file associated with the current buffer. Also, you can not write out a portion of the current buffer to it's associated file without specifying the "!". This protects you from unknowingly clobbering a file. Note that the append operation is not possible. :[l_spec][,l_spec]wq[!] [] This command is identical to typing a ":w" command followed by typing a ":q" command. See the descriptions of those commands for more details. .EL .if system .I-1 3 Write_and_exit .else system .send toc .ifnot global .hl 2 ^*Write and exit\* .send toc .endif global .endif system .s .LT :x{it} Is synomous with typing "ZZ" while in command mode. The contents of the current buffer will be written out if they are modified. All other buffers will then be examined, and you will be asked whether or not you wish to write out any other modified buffer. The ":set nowrite" command will force a modifed buffer to be ignored during this search. .EL