Learning the vi Editor

Learning the vi EditorSearch this book
Previous: A.5 Other ex CommandsAppendix BNext: C. ex commands
 

B. Setting Environment Options

The following table contains brief descriptions of all set command options. In the first column, options are listed in alphabetical order; if the option can be abbreviated, that abbreviation is shown in parentheses on the line below. The second column shows the default setting that vi uses unless you issue an explicit set command (either manually or in the .exrc file). The last column describes what the option does, when enabled.

Table B.1: Set Commands
OptionDefaultDescription
autoindent (ai)noai

In insert mode, indents each line to the same level as the line above or below. Use with shiftwidth option.

autoprint (ap)ap

Displays changes after each editor command. (For global replacement, displays last replacement.)

autowrite (aw)noaw

Automatically writes (saves) file if changed before opening another file with :n or before giving UNIX command with :!.

beautify (bf)nobf

Ignores all control characters during input (except tab, newline, or formfeed).

directory (dir)/tmp

Names directory in which ex stores buffer files. (Directory must be writable.)

edcompatible

noed-compatible

Uses ed-like features on substitute commands.

errorbells (eb)errorbellsSounds bell when an error occurs.
exrc (ex)noexrc

Allows the execution of .exrc files that reside outside the user's home directory. (System V only.)

hardtabs (ht)=8

Defines boundaries for terminal hardware tabs.

ignorecase (ic)noic

Disregards case during a search.

lispnolisp

Inserts indents in appropriate lisp format. ( ), { }, [[, and ]] are modified to have meaning for lisp.

listnolist

Prints tabs as ^I; marks ends of lines with $. (Use list to tell if end character is a tab or a space.)

magicmagic

Wildcard characters . (dot), * (asterisk), and [] (brackets) have special meaning in patterns.

mesgmesg

Permits system messages to display on terminal while editing in vi.

number (nu)nonu

Displays line numbers on left of screen during editing session.

openopen

Allows entry to open or visual mode from ex.

optimize (opt)noopt

Abolishes carriage returns at the end of lines when printing multiple lines, speeds output on dumb terminals when printing lines with leading white space (blanks or tabs).

paragraphs (para)

=IPLPPPQP LIpplpipbp

Defines paragraph delimiters for movement by { or }. The pairs of characters in the value are the names of nroff/troff macros that begin paragraphs.

promptprompt

Displays the ex prompt (:) when vi's Q command is given.

readonly (ro)noro

Any writes (saves) of a file will fail unless you use ! after the write (works with w, ZZ, or autowrite).

redraw (re)noredraw

Terminal redraws screen whenever edits are made (in other words, insert mode pushes over existing characters, and deleted lines immediately close up). Default depends on line speed and terminal type. noredraw is useful at slow speeds on a dumb terminal: deleted lines show up as @, and inserted text appears to overwrite existing text until you press [ESC].

remapremap

Allows nested map sequences.

report=5

Displays a message on the prompt line whenever you make an edit that affects at least a certain number of lines. For example, 6dd reports the message "6 lines deleted."

scroll=[1/2 window]

Amount of screen to scroll.

sections (sect)=SHNHH HU

Defines section delimiters for [[ ]] movement. The pairs of characters in the value are the names of nroff/troff macros that begin sections.

shell (sh)=/bin/sh

Pathname of shell used for shell escape (:!) and shell command (:sh). Default value is derived from shell environment, which varies on different systems.

shiftwidth (sw)=8

Defines number of spaces in backward (^D) tabs when using the autoindent option.

showmatch (sm)nosm

In vi, when ) or } is entered, cursor moves briefly to matching ( or {. (If match is not on the screen, rings the error message bell.) Very useful for programming.

showmodenoshowmode

In insert mode, displays a message on the prompt line indicating the type of insert you are making. For example, "Open Mode," or "Append Mode." (System V only.)

slowopen (slow)

Holds off display during insert. Default depends on line speed and terminal type.

tabstop (ts)=8

Defines number of spaces that a [TAB] indents during editing session. (Printer still uses system tab of 8.)

taglength (tl)=0

Defines number of characters that are significant for tags. Default (zero) means that all characters are significant.

tags

=tags /usr/lib/tags

Defines pathname of files containing tags (see the UNIX ctags command.) (By default, system searches /usr/lib/tags and the file tags in the current directory.)

termSets terminal type.
tersenoterse

Displays shorter error messages.

timeout (to)timeout

Keyboard maps "time out" after 1 second.[1]

ttytypeSets terminal type.
warnwarn

Displays the warning message, "No write since last change."

window (w)

Shows a certain number of lines of the file on the screen. Default depends on line speed and terminal type.

wrapscan (ws)ws

Searches wrap around either end of file.

wrapmargin (wm)=0

Defines right margin. If greater than zero, automatically inserts carriage returns to break lines.

writeany (wa)nowaAllows saving to any file.

[1] This option is rarely needed. It's useful only with versions of vi that let you map a sequence to several keys (for example, :map zzz 3dw). If you set notimeout, you have unlimited time to type the command zzz, instead of the one second you normally have.


Previous: A.5 Other ex CommandsLearning the vi EditorNext: C. ex commands
A.5 Other ex CommandsBook IndexC. ex commands

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System