NOTE: In this document, the word "current," when used in reference to some unit of text, identifies the location of the cursor. For example: current character, current word, current line.
This document also uses several fonts to help clarify the meaning of the text.
fixed | Literal commands you type appear in Courier font |
italic | Variables used with commands will appear in italics |
bold | Keys or elements that you must click appear in bold |
[ ] | Optional variables will appear in square brackets |
There are several ways to save your document and exit Vi. Be sure to use the save command often when editing an important document.
:w | save changes (i.e., write) to your file |
:w | filename save changes (i.e., write) to the file specified |
:q | quit Vi (when you haven't made any changes) |
:q! | quit without saving changes |
:wq or ZZ | save changes to file and then qui |
:! cmd | execute a single command (cmd) and return to vi |
:sh | start up a new UNIX shell - to return to Vi from the shell, type exit or Ctrl-d |
NOTE: The :! and :sh commands make it easy to execute UNIX commands without exiting Vi.
Vi has several options which affect the way Vi functions and alter your editing environment. These options can be set by hand from within Vi (must be reset every time you use Vi), or they can be made permanent (i.e., set automatically) by creating a .exrc file and including the commands there or setting the EXINIT environment variable in your .login or .cshrc file. (Do not alter the .login or .cshrc files.) Use the set all command to get a list of all of the options.
:set | list the currently set editor options |
:set all | list all of the editor options |
:set option=value | set an option that takes a numeric or string value |
:set option | turn on a toggled option |
:set no option | turn off a toggled option |