next up previous contents
Next: Emacs Up: Editing files Previous: Editing files   Contents

Vi

The editor vi has two ``modes'' of operation: command mode and insert mode. In command mode you can move the cursor around the text, and make changes to existing text. To enter new text you must use insert mode. You can get into insert mode with the I or i (insert), A or a (append) and O or o (open line) commands. To exit from insert mode hit the ESC (escape) key; on some terminals the ESC key is the ctrl-[ (control key with the left square bracket).

To edit a file type vi followed by the filename. If you are creating a new file use the same format. To exit from vi type :wq or ZZ. E.g.:

malama% vi params The screen will then clear and at the bottom of the screen there will be a status line. e.g.:

``params'' [New file]

There are two useful features of vi you should know about. First, if you execute a command you wish you hadn't, vi provides a command to undo the last change you made; just type u. The undo command only lets you reverse a single change. To restore a complete line type U ; this will only work if you do not move off the line.

Second, if you are editing a file with vi and the system crashes, don't panic. The system will save the journal file just like in VMS. When the system comes back up you will be sent a mail message to tell you what file you were editing. You can recover your file by using vi -r filename.

Please note that in your ``.login'' and ``.cshrc'' files, which set up your environment, the first time you log on, there will already be some commands for setting up your terminal as a vt102. Since terminal setup can be extremely complicated in UNIX, don't remove what is already there unless you wish to set it up again yourself in some other way. Many screen-oriented programs, like vi, will not work properly if your terminal has not been set up. If you are using a VT220 or VT220 emulator, you should go to the ``General'' screen in Set-up and set your terminal to ``VT100 mode'' (``VT220 ID'' is harmless with it).

To get a basic idea of how to run the editor see ``SUNOS User's Guide: Getting Started''. If you wish to see the many commands for vi, refer to ``Editing Text Files''.


next up previous contents
Next: Emacs Up: Editing files Previous: Editing files   Contents
h.stilmack@jach.hawaii.edu