Set Options
***********

There are a large number of options that may be set (or unset) to change the editor's behavior. This section describes the options, their abbreviations and their default values.

In each entry below, the first part of the tag line is the full name of the option, followed by any equivalent abbreviations. (Regardless of the abbreviations, it is only necessary to use the minimum number of characters necessary to distinguish an abbreviation from all other commands for it to be accepted, in nex,nvi. Historically, only the full name and the official abbreviations were accepted by ex,vi. Using full names in your startup files and environmental variables will probably make them more portable.) The part in square brackets is the default value of the option. Most of the options are boolean, i.e. they are either on or off, and do not have an associated value.

Options apply to both ex and vi modes, unless otherwise specified.

With a few exceptions, all options are settable per screen, i.e. the tags option can be set differently in each screen. The exceptions are the columns, lines, secure and term options. Changing these options modifies the respective information for all screens.

For information on modifying the options or to display the options and their current values, see the set command in the section entitled Ex Commands .

     altwerase [off]

     Vi only. Change how vi does word erase during text input. When this option is set, text is broken up into three classes: alphabetic, numeric and underscore characters, other nonblank characters, and blank characters. Changing from one class to another marks the end of a word. In addition, the class of the first character erased is ignored (which is exactly what you want when erasing pathname components). autoindent, ai [off]

     If this option is set, whenever you create a new line (using the vi A, a, C, c, I, i, O, o, R, r, S, and s commands, or the ex append, change, and insert commands) the new line is automatically indented to align the cursor with the first nonblank character of the line from which you created it. Lines are indented using tab characters to the extent possible (based on the value of the tabstop option) and then using space characters as necessary. For commands inserting text into the middle of a line, any blank characters to the right of the cursor are discarded, and the first nonblank character to the right of the cursor is aligned as described above.

     The indent characters are themselves somewhat special. If you do not enter more characters on the new line before moving to another line, or entering <escape>, the indent character will be deleted and the line will be empty. For example, if you enter <carriage-return>twice in succession, the line created by the first <carriage-return>will not have any characters in it, regardless of the indentation of the previous or subsequent line.

     Indent characters also require that you enter additional erase characters to delete them. For example, if you have an indented line, containing only blanks, the first <word-erase>character you enter will erase up to end of the indent characters, and the second will erase back to the beginning of the line. (Historically, only the <control-D>key would erase the indent characters. Both the <control-D>key and the usual erase keys work in nvi.) In addition, if the cursor is positioned at the end of the indent characters, the keys 0<control-D> will erase all of the indent characters for the current line, resetting the indentation level to 0. Similarly, the keys ^<control-D> will erase all of the indent characters for the current line, leaving the indentation level for future created lines unaffected.

     Finally, if the autoindent option is set, the S and cc commands change from the first nonblank of the line to the end of the line, instead of from the beginning of the line to the end of the line. autoprint, ap [off]

     Ex only. Cause the current line to be automatically displayed after the ex commands <, >, copy, delete, join, move, put, t, Undo, and undo. This automatic display is suppressed during global and v commands, and for any command where optional flags are used to explicitly display the line. autowrite, aw [off]

     If this option is set, the vi !, ^^, ^] and <control-Z> commands, and the ex edit, next, rewind, stop, suspend, tag, tagpop, and tagtop commands automatically write the current file back to the current file name if it has been modified since it was last written. If the write fails, the command fails and goes no further.

     Appending the optional force flag character ! to the ex commands next, rewind, stop, suspend, tag, tagpop, and tagtop stops the automatic write from being attempted.

     (Historically, the next command ignored the optional force flag.) Note, the ex commands edit, quit, shell, and xit are not affected by the autowrite option.

     The autowrite option is ignored if the file is considered read-only for any reason. backup [""]

     If this option is set, it specifies a pathname used as a backup file, and, whenever a file is written, the file's current contents are copied to it. The pathname is #, % and ! expanded.

     If the first character of the pathname is N, a version number is appended to the pathname (and the N character is then discarded). Version numbers are always incremented, and each backup file will have a version number one greater than the highest version number currently found in the directory.

     Backup files must be regular files, owned by the real user ID of the user running the editor, and not accessible by any other user. beautify, bf [off]

     If this option is set, all control characters that are not currently being specially interpreted, other than <tab>, <newline>, and <form-feed>, are discarded from commands read in by ex from command files, and from input text entered to vi (either into the file or to the colon command line). Text files read by ex,vi are not affected by the beautify option. cdpath [environment variable CDPATH, or current directory]

     This option is used to specify a colon separated list of directories which are used as path prefixes for any relative path names used as arguments for the cd command. The value of this option defaults to the value of the environmental variable CDPATHif it is set, otherwise to the current directory. For compatibility with the POSIX 1003.2 shell, the cd command does not check the current directory as a path prefix for relative path names unless it is explicitly specified. It may be so specified by entering an empty string or a . character into the CDPATHvariable or the option value. cedit [no default]

     This option adds the ability to edit the colon command-line history. This option is set to a string. Whenever the first character of that string is entered on the colon command line, you will enter a normal editing window on the collected commands that you've entered on the vi colon command-line. You may then modify and/or execute the commands. All normal text editing is available, except that you cannot use <control-W> to switch to an alternate screen. Entering a <carriage-return> will execute the current line of the screen window as an ex command in the context of the screen from which you created the colon command-line screen, and you will then return to that screen.

     Because of vi's parsing rules, it can be difficult to set the colon command-line edit character to the <escape>character. To set it to <escape>, use set cedit=<literal-next><escape>.

     If the cedit edit option is set to the same character as the filec edit option, vi will perform colon command-line editing if the character is entered as the first character of the line, otherwise, vi will perform file name expansion. columns, co [80]

     The number of columns in the screen. Setting this option causes ex,vi to set (or reset) the environmental variable COLUMNS. See the section entitled Sizing the Screen more information. comment [off]

     Vi only. If the first non-empty line of the file begins with the string #, /* or //, this option causes vi to skip to the end of that shell, C or C++ comment (probably a terribly boring legal notice) before displaying the file. directory, dir [environment variable TMPDIR, or /tmp]

     The directory where temporary files are created. The environmental variable TMPDIRis used as the default value if it exists, otherwise /tmpis used. edcompatible, ed [off]

     Remember the values of the c and g suffixes to the substitute commands, instead of initializing them as unset for each new command. Specifying pattern and replacement strings to the substitute command unsets the c and g suffixes as well. escapetime [1]

     The 10th's of a second ex,vi waits for a subsequent key to complete an <escape>key mapping. errorbells, eb [off]

     Ex only. Ex error messages are normally presented in inverse video. If that is not possible for the terminal, setting this option causes error messages to be announced by ringing the terminal bell. exrc, ex [off]

     If this option is turned on in the EXINIT environment variables, or the system or $HOME startup files, the local startup files are read, unless they are the same as the system or $HOME startup files or fail to pass the standard permission checks. See the section entitled Startup Information for more information. extended [off]

     This option causes all regular expressions to be treated as POSIX 1003.2 Extended Regular Expressions (which are similar to historic egrep,1 style expressions). filec [no default]

     This option adds the ability to do shell expansion when entering input on the colon command line. This option is set to a string. Whenever the first character of that string is entered on the colon command line, the <blank> delimited string immediately before the cursor is expanded as if it were followed by a *character, and file name expansion for the ex edit command was done. If no match is found, the screen is flashed and text input resumed. If a single match results, that match replaces the expanded text. In addition, if the single match is for a directory, a /character is appended and file completion is repeated. If more than a single match results, any unique prefix shared by the matches replaces the expanded text, the matches are displayed, and text input resumed.

     Because of vi's parsing rules, it can be difficult to set the path completion character to two command values, <escape>and <tab>. To set it to <escape>, use set filec=<literal-next><escape>. To set it to <tab>, use set filec=\e<tab>.

     If the cedit edit option is set to the same character as the filec edit option, vi will perform colon command-line editing if the character is entered as the first character of the line, otherwise, vi will perform file name expansion. flash [on]

     This option causes the screen to flash instead of beeping the keyboard, on error, if the terminal has the capability. hardtabs, ht [8]

     This option defines the spacing between hardware tab settings, i.e. the tab expansion done by the operating system and/or the terminal itself. As nex,nvi never writes <tab>characters to the terminal, unlike historic versions of ex,vi, this option does not currently have any affect. iclower [off]

     The iclower edit option makes all Regular Expressions case-insensitive, as long as an upper-case letter does not appear in the search string. ignorecase, ic [off]

     This option causes regular expressions, both in ex commands and in searches, to be evaluated in a case-insensitive manner. keytime [6]

     The 10th's of a second ex,vi waits for a subsequent key to complete a key mapping. leftright [off]

     Vi only. This option causes the screen to be scrolled left-right to view lines longer than the screen, instead of the traditional vi screen interface which folds long lines at the right-hand margin of the terminal. lines, li [24]

     Vi only. The number of lines in the screen. Setting this option causes ex,vi to set (or reset) the environmental variable LINES. See the section entitled Sizing the Screen for more information. lisp [off]

     Vi only. This option changes the behavior of the vi (, ), {, }, [[ and ]] commands to match the Lisp language. Also, the autoindent option's behavior is changed to be appropriate for Lisp.

     This option is not yet implemented. list [off]

     This option causes lines to be displayed in an unambiguous fashion. Specifically, tabs are displayed as control characters, i.e. ^I, and the ends of lines are marked with a $ character. lock [on]

     This option causes the editor to attempt to get an exclusive lock on any file being edited, read or written. Reading or writing a file that cannot be locked produces a warning message, but no other effect. Editing a file that cannot be locked results in a read only edit session, as if the readonly edit option were set. magic [on]

     This option is on by default. Turning the magic option off causes all regular expression characters except for ^ and $, to be treated as ordinary characters. To re-enable characters individually, when the magic option is off, precede them with a backslash \e character. See the section entitled Regular Expressions and Replacement Strings for more information. matchtime [7]

     Vi only. The 10th's of a second vi pauses on the matching character when the showmatch option is set. mesg [on]

     This option allows other users to contact you using the talk,1 and write,1 utilities, while you are editing. Ex,vi does not turn message on, i.e. if messages were turned off when the editor was invoked, they will stay turned off. This option only permits you to disallow messages for the edit session. See the mesg,1 utility for more information. msgcat [./]

     This option selects a message catalog to be used to display error and informational messages in a specified language. If the value of this option ends with a '/', it is treated as the name of a directory that contains a message catalog vi_XXXX, where XXXX is the value of the LANGenvironmental variable, if it's set, or the value of the LC_MESSAGESenvironmental variable if it's not. If neither of those environmental variables are set, or if the option doesn't end in a '/', the option is treated as the full path name of the message catalog to use.

     If any messages are missing from the catalog, the backup text (English) is used instead.

     See the distribution file catalog/READMEfor additional information on building and installing message catalogs. modelines, modeline [off]

     If the modelines option is set, ex,vi has historically scanned the first and last five lines of each file as it is read for editing, looking for any ex commands that have been placed in those lines. After the startup information has been processed, and before the user starts editing the file, any commands embedded in the file are executed.

     Commands were recognized by the letters e or v followed by x or i, at the beginning of a line or following a tab or space character, and followed by a :, an ex command, and another :.

     This option is a security problem of immense proportions, and should not be used under any circumstances.

     This option will never be implemented. noprint [""]

     Characters that are never handled as printable characters. By default, the C library function isprint,3 is used to determine if a character is printable or not. This edit option overrides that decision. number, nu [off]

     Precede each line displayed with its current line number. octal [off]

     Display unknown characters as octal numbers "\e###", instead of the default hexadecimal "\ex##". open [on]

     Ex only. If this option is not set, the open and visual commands are disallowed. optimize, opt [on]

     Vi only. Throughput of text is expedited by setting the terminal not to do automatic carriage returns when printing more than one (logical) line of output, greatly speeding output on terminals without addressable cursors when text with leading white space is printed.

     This option is not yet implemented. paragraphs, para [IPLPPPQPP LIpplpipbp]

     Vi only. Define additional paragraph boundaries for the { and } commands. The value of this option must be a character string consisting of zero or more character pairs.

     In the text to be edited, the character string <newline>.<char-pair>, (where <char-pair>is one of the character pairs in the option's value) defines a paragraph boundary. For example, if the option were set to LaA<space>##, then all of the following additional paragraph boundaries would be recognized:

          <newline>.La
          <newline>.A<space>
          <newline>.##

     path []

     The path option can be used to specify a <colon>-separated list of paths, similar to the PATHenvironment variable in the shells. If this option is set, the name of the file to be edited is not an absolute pathname, the first component of the filename is not . or .., and the file to be edited doesn't exist in the current directory, the elements of the path option are sequentially searched for a file of the specified name. If such a file is found, it is edited. print [""]

     Characters that are always handled as printable characters. By default, the C library function isprint,3 is used to determine if a character is printable or not. This edit option overrides that decision. prompt [on]

     Ex only. This option causes ex to prompt for command input with a : character; when it is not set, no prompt is displayed. readonly, ro [off]

     This option causes a force flag to be required to attempt to write the file. Setting this option is equivalent to using the -R command line option, or executing the vi program using the name view.

     The readonly edit option is not usually persistent, like other edit options. If the -R command line option is set, vi is executed as view, or the readonly edit option is explicitly set, all files edited in the screen will be marked readonly, and the force flag will be required to write them. However, if none of these conditions are true, or the readonly edit option is explicitly unset, then the readonly edit option will toggle based on the write permissions of the file currently being edited as of when it is loaded into the edit buffer. In other words, the readonly edit option will be set if the current file lacks write permissions, and will not be set if the user has write permissions for the file. recdir [/var/tmp/vi.recover]

     The directory where recovery files are stored.

     If you change the value of recdir, be careful to choose a directory whose contents are not regularly deleted. Bad choices include directories in memory based filesystems, or /tmp, on most systems, as their contents are removed when the machine is rebooted.

     Public directories like /usr/tmpand /var/tmpare usually safe, although some sites periodically prune old files from them. There is no requirement that you use a public directory, e.g. a sub-directory of your home directory will work fine.

     Finally, if you change the value of recdir, you must modify the recovery script to operate in your chosen recovery area.

     See the section entitled Recovery for further information. redraw, re [off]

     Vi only. The editor simulates (using great amounts of output), an intelligent terminal on a dumb terminal (e.g. during insertions in vi the characters to the right of the cursor are refreshed as each input character is typed).

     This option is not yet implemented. remap [on]

     If this option is set, it is possible to define macros in terms of other macros. Otherwise, each key is only remapped up to one time. For example, if A is mapped to B, and B is mapped to C, The keystroke A will be mapped to C if the remap option is set, and to B if it is not set. report [5]

     Set the threshold of the number of lines that need to be changed or yanked before a message will be displayed to the user. For everything but the yank command, the value is the largest value about which the editor is silent, i.e. by default, 6 lines must be deleted before the user is notified. However, if the number of lines yanked is greater than or equal to the set value, it is reported to the user. ruler [off]

     Vi only. Display a row/column ruler on the colon command line. scroll, scr [(environment variable LINES - 1) / 2]

     Set the number of lines scrolled by the ex <control-D> and <end-of-file> commands.

     Historically, the ex z command, when specified without a count, used two times the size of the scroll value; the POSIX 1003.2 standard specified the window size, which is a better choice. searchincr [off]

     The searchincr edit option makes the search commands / and ? incremental, i.e. the screen is updated and the cursor moves to the matching text as the search pattern is entered. If the search pattern is not found, the screen is beeped and the cursor remains on the colon-command line. Erasing characters from the search pattern backs the cursor up to the previous matching text. sections, sect [NHSHH HUnhsh]

     Vi only. Define additional section boundaries for the [[ and ]] commands. The sections option should be set to a character string consisting of zero or more character pairs. In the text to be edited, the character string <newline>.<char-pair>, (where <char-pair>is one of the character pairs in the option's value), defines a section boundary in the same manner that paragraphs option boundaries are defined. secure [off]

     The secure edit option turns off all access to external programs. This means that the versions of the read and write commands that filter text through other programs, the vi ! and <control-Z> commands, the ex !, script, shell, stop and suspend commands and file name expansion will not be permitted. Once set, the secure edit option may not be unset. shell, sh [environment variable SHELL, or /bin/sh]

     Select the shell used by the editor. The specified path is the pathname of the shell invoked by the vi ! shell escape command and by the ex shell command. This program is also used to resolve any shell meta-characters in ex commands.

  * shellmeta [~{[*?$`'"\]

     The set of characters that ex checks for when doing file name expansion. If any of the specified characters are found in the file name arguments to the ex commands, the arguments are expanded using the program defined by the shell option. The default set of characters is a union of meta characters from the Version 7 and the Berkeley C shell. shiftwidth, sw [8]

     Set the autoindent and shift command indentation width. This width is used by the autoindent option and by the <, >, and shift commands. showmatch, sm [off]

     Vi only. This option causes vi, when a ``}'' or ) is entered, to briefly move the cursor the matching ``{'' or (. See the matchtime option for more information. showmode, smd [off]

     Vi only. This option causes vi to display a string identifying the current editor mode on the colon command line. The string is preceded by an asterisk (``*'') if the file has been modified since it was last completely written, sidescroll [16]

     Vi only. Sets the number of columns that are shifted to the left or right, when vi is doing left-right scrolling and the left or right margin is crossed. See the leftright option for more information. slowopen, slow [off]

     This option affects the display algorithm used by vi, holding off display updating during input of new text to improve throughput when the terminal in use is slow and unintelligent.

     This option is not yet implemented. sourceany [off]

     If this option is turned on, vi historically read startup files that were owned by someone other than the editor user. See the section entitled Startup Information for more information. This option is a security problem of immense proportions, and should not be used under any circumstances.

     This option will never be implemented. tabstop, ts [8]

     This option sets tab widths for the editor display. taglength, tl [0]

     This option sets the maximum number of characters that are considered significant in a tag name. Setting the value to 0 makes all of the characters in the tag name significant. tags, tag [tags /var/db/libc.tags /sys/kern/tags]

     Sets the list of tags files, in search order, which are used when the editor searches for a tag. term, ttytype, tty [environment variable TERM]

     Set the terminal type. Setting this option causes ex,vi to set (or reset) the environmental variable TERM. terse [off]

     This option has historically made editor messages less verbose. It has no effect in this implementation. See the verbose option for more information. tildeop [off]

     Modify the ~ command to take an associated motion. timeout, to [on]

     If this option is set, ex,vi waits for a specific period for a subsequent key to complete a key mapping (see the keytime option). If the option is not set, the editor waits until enough keys are entered to resolve the ambiguity, regardless of how long it takes. ttywerase [off]

     Vi only. This option changes how vi does word erase during text input. If this option is set, text is broken up into two classes, blank characters and nonblank characters. Changing from one class to another marks the end of a word. verbose [off]

     Vi only. Vi historically bells the terminal for many obvious mistakes, e.g. trying to move past the left-hand margin, or past the end of the file. If this option is set, an error message is displayed for all errors. w300 [no default]

     Vi only. Set the window size if the baud rate is less than 1200 baud. See the window option for more information. w1200 [no default]

     Vi only. Set the window size if the baud rate is equal to 1200 baud. See the window option for more information. w9600 [no default]

     Vi only. Set the window size if the baud rate is greater than 1200 baud. See the window option for more information. warn [on]

     Ex only. This option causes a warning message to the terminal if the file has been modified, since it was last written, before a ! command. window, w, wi [environment variable LINES - 1]

     This option determines the default number of lines in a screenful, as displayed by the z command. It also determines the number of lines scrolled by the vi commands <control-B> and <control-F>, and the default number of lines scrolled by the vi commands <control-D> and <control-U>. The value of window can be unrelated to the real screen size, although it starts out as the number of lines on the screen. See the section entitled Sizing the Screen for more information. Setting the value of the window option is the same as using the -w command line option.

     If the value of the window option (as set by the window, w300, w1200 or w9600 options) is smaller than the actual size of the screen, large screen movements will result in displaying only that smaller number of lines on the screen. (Further movements in that same area will result in the screen being filled.) This can provide a performance improvement when viewing different places in one or more files over a slow link.

     Resetting the window size does not reset the default number of lines scrolled by the <control-D> and <control-U> commands. windowname [off]

     Vi changes the name of the editor's icon/window to the current file name when it's possible and not destructive, i.e., when the editor can restore it to its original value on exit or when the icon/window will be discarded as the editor exits. If the windowname edit option is set, vi will change the icon/window name even when it's destructive and the icon/window name will remain after the editor exits. (This is the case for xterm,1). wraplen, wl [0]

     This option is identical to the wrapmargin option, with the exception that it specifies the number of columns from the left margin before the line splits, not the right margin.

     If both wraplen and wrapmargin are set, the wrapmargin value is used. wrapmargin, wm [0]

     Vi only. If the value of the wrapmargin option is non-zero, vi will split lines so that they end at least that number of columns before the right-hand margin of the screen. (Note, the value of wrapmargin is not a text length. In a screen that is 80 columns wide, the command :set wrapmargin=8 attempts to keep the lines less than or equal to 72 columns wide.)

     Lines are split at the previous whitespace character closest to the number. Any trailing whitespace characters before that character are deleted. If the line is split because of an inserted <space>or <tab>character, and you then enter another <space>character, it is discarded.

     If wrapmargin is set to 0, or if there is no blank character upon which to split the line, the line is not broken.

     If both wraplen and wrapmargin are set, the wrapmargin value is used. wrapscan, ws [on]

     This option causes searches to wrap around the end or the beginning of the file, and back to the starting point. Otherwise, the end or beginning of the file terminates the search. writeany, wa [off]

     If this option is set, file-overwriting checks that would usually be made before the write and xit commands, or before an automatic write (see the autowrite option), are not made. This allows a write to any file, provided the file permissions allow it.