start page | rating of books | rating of authors | reviews | copyrights

Linux in a NutshellLinux in a NutshellSearch this book

11.15. vi Configuration

This section describes the following:

11.15.1. The :set Command

The :set command lets you specify options that change characteristics of your editing environment. Options may be put in the ~/.exrc file or set during a vi session.

The colon should not be typed if the command is put in ~/.exrc.

Command

Action

:set x

Enable option x.

:set nox

Disable option x.

:set x=val

Give value to option x.

:set

Show changed options.

:set all

Show all options.

:set x?

Show value of option x.

11.15.2. Options Used by :set

The following table describes the options to :set. The first column includes the optional abbreviation, if there is one, and uses an equals sign to show that the option takes a value. The second column gives the default, and the third column describes the behavior of the enabled option.

Option

Default

Description

autoindent (ai)

noai

In insert mode, indent each line to the same level as the line above or below.

autoprint (ap)

ap

Display changes after each editor command. (For global replacement, display last replacement.)

autowrite (aw)

noaw

Automatically write (save) file if changed, before opening another file with :n or before giving a Linux command with :!.

background (bg)

Describe the background so the editor can choose appropriate highlighting colors. Default value of dark or light depends on the environment in which the editor is invoked. {vim}

backup (bk)

nobackup

Create a backup file when overwriting an existing file. {vim}

backupdir= (bdir)

.,~/tmp/,~/

Name directories in which to store backup files if possible. The list of directories is comma-separated and in order of preference. {vim}

backupext= (bex)

~

String to append to filenames for backup files. {vim}

beautify (bf)

nobf

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

cindent (cin)

nocindent

Insert indents in appropriate C format. {vim}

compatible (cp)

cp

Make vim behave more like vi. Default is nocp when a ~/.vimrc file is found. {vim}

directory= (dir)

/tmp

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

edcompatible

noed-compatible

Use ed-like features on substitute commands.

equalprg= (ep)

Use the specified program for the = command. When the option is blank (the default), the key invokes the internal C indention function or the value of the indentexpr option. {vim}

errorbells (eb)

errorbells

Sound bell when an error occurs.

exrc (ex)

noexrc

Allow the execution of ~/.exrc files that reside outside the user's home directory.

formatprg= (fp)

The gq command will invoke the named external program to format text. It will call internal formatting functions when this option is blank (the default). {vim}

gdefault (gd)

nogdefault

Set the g flag on for substitutions by default. {vim}

hardtabs= (ht)

8

Define boundaries for terminal hardware tabs.

hidden (hid)

nohidden

Hide buffers rather than unload them when they are abandoned. {vim}

hlsearch (hls)

hlsearch

Highlight all matches of most recent search.

history= (hi)

20

Number of ex commands to store in the history table. {vim}

ignorecase (ic)

noic

Disregard case during a search.

incsearch (is)

noincsearch

Highlight matches to a search pattern as it is typed. {vim}

lisp

nolisp

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

list

nolist

Print tabs as ^I; mark ends of lines with $. (Use list to tell if tabs or spaces are at the end of a line.)

magic

magic

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

mesg

mesg

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

mousehide (mh)

mousehide

When characters are typed, hide the mouse pointer. {vim}

number (nu)

nonu

Display line numbers on left of screen during editing session.

paste

nopaste

Change the defaults of various options to make pasting text into a terminal window work better. All options are returned to their original value when the paste option is reset. {vim}

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.

remap

remap

Allow nested map sequences.

report=

5

Display 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."

ruler (ru)

ruler

Show line and column numbers for the current cursor position. {vim}

scroll=

<1/2 window>

Amount of screen to scroll.

sections= (sect)

SHNHH HUnhsh

Define 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 variable.

shiftwidth= (sw)

8

Define number of spaces used by the indent commands (^T, ^D, >>, and <<).

showmatch (sm)

nosm

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

showmode

noshowmode

In insert mode, displays a message on the prompt line indicating the type of insert you are making, such as "Open Mode" or "Append Mode."

slowopen (slow)

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

smartcase (scs)

nosmartcase

Override the ignorecase option when a search pattern contains uppercase characters. {vim}

tabstop= (ts)

8

Define number of spaces that a tab indents during editing session. (Printer still uses system tab of 8.)

taglength= (tl)

0

Define number of characters that are significant for tags. Default (0) means that all characters are significant.

tags=

tags /usr/lib/tags

Define pathname of files containing tags (see the ctags command in Chapter 3). By default, the system looks for files tags (in the current directory) and /usr/lib/tags.

term=

Set terminal type.

terse

noterse

Display shorter error messages.

timeout (to)

timeout

Keyboard maps timeout after 1 second.

ttytype=

Set terminal type. Default is inherited from TERM environment variable.

undolevels= (ul)

1000

Number of changes that can be undone. {vim}

warn

warn

Display the message "No write since last change."

window= (w)

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

wrapmargin= (wm)

0

Define right margin. If greater than 0, automatically insert carriage returns to break lines.

wrapscan (ws)

ws

Searches wrap around either end of file.

writeany (wa)

nowa

Allow saving to any file.

writebackup (wb)

wb

Back up files before attempting to overwrite them. Remove the backup when the file has been sucessfully written.

11.15.3. Sample ~/.exrc File

The following lines of code are an example of a customized .exrc file:

set nowrapscan wrapmargin=7
set sections=SeAhBhChDh nomesg
map q :w^M:n^M
map v dwElp
ab ORA O'Reilly & Associates, Inc.


Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.