home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeLearning the vi EditorSearch this book

C.4. vim 5.1 Options

vim 5.1 has a total of 170 options that affect its behavior. Table C.4 summarizes the most important ones. Most options described in Table C.1 are not repeated here.

The summaries in the table here are of necessity very brief. Much more information about each option may be found in the vim online help.

Table C.4. vim 5.1 Set Options

Option

Default

Description

background (bg)

dark or light

vim tries to use background and foreground colors that are appropriate to the particular terminal.

backspace (bs)

0

Controls whether you can backspace over a newline and/or over the start of insert. Values are: 0 for vi compatibility, 1 to backspace over newlines, and 2 to backspace over the start of insert. Using a value of 3 allows both.

backup (bk)

nobackup

Make a backup before overwriting a file, then leave it around after the file has been successfully written. To have a backup file just while the file is being written, use the writebackup option.

backupdir (bdir)

., ~/tmp/, ~/

A list of directories for the backup file, separated with commas. The backup file will be created in the first directory in the list where this is possible. If empty, you cannot create a backup file. The name . (dot) means the same directory as where the edited file is.

backupext (bex)

~

The string which is appended to a file name to make the name of the backup file.

binary (bin)

nobinary

Changes a number of other options to make it easier to edit binary files. The previous values of these options are remembered and restored when bin is switched back off. Each buffer has its own set of saved option values. This option should be set before editing a binary file. You can also use the -b command line option.

cindent (cin)

nocindent

Enables automatic smart C program indenting.

cinkeys (cink)

0{,0},:,0#,!^F, o,O,e

A list of keys that, when typed in insert mode, cause reindenting of the current line. Only happens if cindent is on.

cinoptions (cino)

 

Affects the way cindent reindents lines in a C program. See the online help for details.

cinwords (cinw)

if, else, while, do, for, switch

These keywords start an extra indent in the next line when smartindent or cindent is set. For cindent this is only done at an appropriate place (inside {...}).

comments (com)

 

A comma-separated list of strings that can start a comment line. See the online help for details.

compatible (cp)

cp; nocp when a .vimrc file is found

Makes vim behave more like vi in too many ways to describe here. It is on by default, to avoid surprises. Having a .vimrc turns off the vi compatibility; usually this is a desirable side effect.

cpoptions (cpo)

aABceFs

A sequence of single character flags, each one indicating a different way in which vim will or will not exactly mimic vi. When empty, the vim defaults are used. See the on-line help for details.

define (def)

^#\s*define

A search pattern that describes macro definitions. The default value is for C programs. For C++, use ^\(#\s*define\ |[a-z]*\s*const\s*[a-z]*\). When using the :set command, you need to double the backslashes.

directory (dir)

., ~/tmp, /tmp

A list of directory names for the swap file, separated with commas. The swap file will be created in the first directory where this is possible. If empty, no swap file will be used and recovery is impossible! The name . (dot) means to put the swap file in the same directory as the edited file. Using . first in the list is recommended so that editing the same file twice will result in a warning.

equalprg (ep)

 

External program to use for = command. When this option is empty the internal formatting functions are used.

errorfile (ef)

errors.err

Name of the errorfile for the quickfix mode. When the -q command line argument is used, errorfile is set to the following argument.

errorformat (efm)

(too long to print)

Scanf-like description of the format for the lines in the error file.

expandtab (et)

noexpandtab

When inserting a tab, expand it to the appropriate number of spaces.

fileformat (ff)

unix

Describes the convention to terminate lines when reading/writing the current buffer. Possible values are dos (CR-LF), unix (LF), and mac (CR). vim will usually set this automatically.

fileformats (ffs)

dos,unix

Lists the line-terminating conventions that vim will try to apply to a file when reading. Multiple names enable automatic end-of-line detection when reading a file.

formatoptions (fo)

vim default: tcq, vi default: vt

A sequence of letters which describes how automatic formatting is to be done. See the online help for details.

gdefault (gd)

nogdefault

Causes the substitute command to change all instances.

guifont (gfn)

 

A comma-separated list of fonts to try when starting the GUI version of vim.

hidden (hid)

nohidden

Hides the current buffer when it is unloaded from a window, instead of abandoning it.

hlsearch (hls)

nohlsearch

Highlight all matches of the most recent search pattern.

history (hi)

vim default: 20, vi default: 0

Controls how many ex commands, search strings and expressions are remembered in the command history.

icon

noicon

vim attempts to change the name of the icon associated with the window where it is running. Overridden by the iconstring option.

iconstring

 

String value used for the icon name of the window.

include (inc)

^#\s*include

Defines a search pattern for finding include commands. The default value is for C programs.

incsearch (is)

noincsearch

Enables incremental searching.

isfname (isf)

@,48-57,/,.,-,_, +,,,$,:,~

A list of characters that can be included in file and path names. Non-UNIX systems have different default values. The @ character stands for any alphabetic character. It is also used in the other isXXX options, below.

isident (isi)

@,48-57,_,192-255

A list of characters that can be included in identifiers. Non-UNIX systems may have different default values.

iskeyword (isk)

@,48-57,_,192-255

A list of characters that can be included in keywords. Non-UNIX systems may have different default values. Keywords are used in searching and recognizing with many commands, such as w, [i, and many more.

isprint (isp)

@,161-255

A list of characters that can be displayed directly to the screen. Non-UNIX systems may have different default values.

makeef (mef)

/tmp/vim##.err

The errorfile name for the :make command. Non-UNIX systems have different default values. The ## is replaced by a number to make the name unique.

makeprg (mp)

make

The program to use for the :make command. % and # in the value are expanded.

mouse

 

Enable the mouse in non-GUI versions of vim. This works for MS-DOS, Win32, and xterm. See the online help for details.

mousehide (mh)

nomousehide

Hides the mouse pointer during typing. Restores the pointer when the mouse is moved.

paste

nopaste

Changes a large number of options so that pasting into a vim window with a mouse does not mangle the pasted text. Turning it off restores those options to their previous values. See the online help for details.

ruler (ru)

noruler

Shows the line and column number of the cursor position.

secure

nosecure

Disables certain kinds of commands in the startup file. Automatically enabled if you don't own the .vimrc and .exrc files.

shellpipe (sp)

 

The shell string to use for capturing the output from :make into a file. The default value depends upon the shell.

shellredir (srr)

 

The shell string for capturing the output of a filter into a temporary file. The default value depends upon the shell.

showmode (smd)

vim default: smd, vi default: nosmd

Put a message in the status line for insert, replace, and visual modes.

sidescroll (ss)

0

How many columns to scroll horizontally. The value zero puts the cursor in the middle of the screen.

smartcase (scs)

nosmartcase

Overrides the ignorecase option if the search pattern contains uppercase characters.

suffixes

*.bak,~,.o,.h, .info,.swp

When multiple files match a pattern during filename completion, the value of this variable sets a priority among them, in order to pick the one vim will actually use.

taglength (tl)

0

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

tagrelative (tr)

vim default: tr, vi default: notr

Filenames in a tags file from another directory are taken to be relative to the directory where the tags file is.

tags (tag)

./tags,tags

Filenames for the :tag command, i.e., add the colon and put the whole thing in courier, separated by spaces or commas. The leading ./ is replaced with the full path to the current file.

tildeop (top)

notildeop

Makes the ~ command behave like an operator.

undolevels (ul)

1000

The maximum number of changes that can be undone. A value of 0 means vi compatibility: one level of undo and u undoes itself. Non-UNIX systems may have different default values.

viminfo (vi)

 

Reads the viminfo file upon startup and writes it upon exiting. The value is complex; it controls the different kinds of information that vim will store in the file. See the online help for details.

writebackup (wb)

writebackup

Make a backup before overwriting a file. The backup is removed after the file was successfully written, unless the backup option is also on.



Library Navigation Links

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