All DECS accounts are set to utilize VI.
To begin editing a file, at the system prompt type:
vi filename
Note that the editor does not directly modify the file which you are editing; the editor makes a copy of this file in the buffer and remembers the file's name. You do not affect the contents of the file until you write the changes you have made into the original file.
There are two modes in VI: MOVING and INSERTING. In MOVING mode, you can move about your document with the 'arrow' keys, delete characters or lines of text as well as perform "cut and paste", search, or "search and replace" functions. In INSERTING MODE you can add text to your current document.
Example: :1,100s/dog/cat
will search from line 1 through 100 and replace all occurrances of the string 'dog' with the string 'cat'.
VI will only find the first occurrance PER LINE of the search string (i.e. dog), unless you specify that you want it to match every occurance on each line. This can be done by adding /g onto the end of your search command.
Example: :1,100s/dog/cat/g
22dd - Delete 22 lines under the cursor 22yy - "Yank" 22 lines into the buffer 22k - Move Up 22 lines from current cursor position 22x - Delete 22 characters from current cursor position --> right
To insert text you must be in INSERT MODE. To enter this mode, press one of the following one-key commands:
Once you have completed your text, you can get back into MOVING MODE by pressing the ESCAPE key.
In order to enter save/quit commands in VI you must be at the 'colon prompt'. This prompt may be obtained by being in MOVING MODE and pressing the colon key. A colon will be displayed at the bottom of your window along with your cursor. Enter the following commands at this prompt to quit and/or save:
q - "Quit" (Exits VI only if you haven't "changed/edited" your file)
q! - "Unconditional quit" (Exits VI even if you "changed" your file)
wq - "Write and Quit" (Saves your file and exits VI)
w - Write your file to a new filename
w! - "Unconditional Write" (Saves your current file and stays in VI)
Below are VI variables that control the operation of your VI session. They can be set from within your session (using : set) and also initialized by the EXINIT environment variable or the .exrc file.
Since the system login file /opt/lib/sys.login contains sets EXINIT and use of system files is perfered I would recommend customizing your vi variables in your .cshrc file using a line similar to the following:
setenv EXINIT 'set ai redraw sm exrc wm=5'
While using vi, type:
:set all
to get the following list:
---------------------- vi variables ---------------------
autoindent nomodelines noshowmode autoprint nonumber noslowopen noautowrite nonovice tabstop=8 nobeautify nooptimize taglength=0 directory=/var/tmp paragraphs=IPLPPPQPP LIpplpipnpbtags=tags /usr/lib/tags noedcompatible prompt tagstack noerrorbells noreadonly term=xterm noexrc redraw noterse flash remap timeout hardtabs=8 report=5 ttytype=xterm noignorecase scroll=12 warn nolisp sections=NHSHH HUuhsh+c window=24 nolist shell=/bin/csh wrapscan magic shiftwidth=8 wrapmargin=0 mesg showmatch nowriteany