Prepared by L. Kocbach, Jan Kocbach and Sturle Drageset NORDPLUS course March 1993 ----------- Editor VI ----------- VI is a standard editor which you find on all Unix installations. It is an absolute standard, which makes it extremely valuable. It can be used from any type of terminal. This latter fact makes it important. There are usually other editors, more comfortable, but specific to a given installation. Because of it's generality, VI should be known to any serious user. Starting VI : 1. The system must know your terminal. If you are in C-shell (see explanation), you can specify it by : setenv TERM vt100 (from most PC'es) setenv TERM sun (from sun sunview) setenv TERM xterm (from X-windows) 2. vi filename vi (Starts with an empty file) 3. Input mode : i Simply type the , and input starts from cursor position. s As i, but the character at cursor position is first removed. o Input starts from next line. O Input starts above the line. Input mode continues until you press -key. 4. Colon commands. :123 Brings you to line 123. :$ Brings you to last line. :1 Brings you to first line. :s/a/hello Replaces the first a by hello. :s/bye/hello/g Replaces all bye on the line by hello. :1,$s/a/hello Does it from line 1 to the end. :se number Shows line-numbers for all lines. :se nonumber Shows no linenumbers. :r otherfile Inserts the file otherfile after the cursors line. :5,10d Deletes lines 5 to 10. :1,$d Cleans the file. :w Store the text on the file. :w filename Store the text as filename. :q Quit program. 5. Moving up and down the file : -u up 1/2 page. -d down 1/2 page. 6. Searching for text. :/hello locates hello. brings you to next hello, to previous. 7. Show parameters. :se Shows all the parameters you can set. This completes the VI minimum. With these features you can do a lot of typical tasks. To execute a system-command (e.g. ls -l *.txt) : !ls -l *.txt Other editors on a given workstation : Hp-motif nedit filename & sparc-atom xedit filename & ...... running X-windows Macintosh Any textprocessor. C-compiler's editor is easy to use. Next point at it. These are easy yo use and are recommended for most of the tasks. However, except for the X-windows, they cannot be used across the networks.