Save a File and Quit Vi Text Editor for UNIX

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.

fixedLiteral commands you type appear in Courier font
 italicVariables used with commands will appear in italics
 boldKeys 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
:wfilename  save changes (i.e., write) to the file specified
:qquit Vi (when you haven't made any changes)
:q!quit without saving changes
:wq or ZZsave changes to file and then qui
:! cmdexecute a single command (cmd) and return to vi
:shstart 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.

:setlist the currently set editor options
:set alllist all of the editor options
:set option=valueset an option that takes a numeric or string value
:set optionturn on a toggled option
:set no optionturn off a toggled option