免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: projl
打印 上一主题 下一主题

《Learning the vi editor》 [复制链接]

论坛徽章:
0
271 [报告]
发表于 2008-06-11 16:28 |只看该作者
(brackets) have special meaning in patterns.
mesg mesg Permits system messages to display on terminal
while editing in vi.
novice nonovice Requires the use of long ex command names,
such as copy or read.
number (nu) nonu Displays line numbers on left of screen during
editing session.
open open
Allows entry to open or visual mode from ex.
Although not in Solaris 2.6 vi, this option has
traditionally been in vi, and may be in your
UNIX's version of vi.
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
whitespace (spaces or tabs).
paragraphs(para)
IPLPPPQPLIpplpipbp
Defines paragraph delimiters for movement by
{ or }. The pairs of characters in the value are
the names of troff macros that begin
paragraphs.
prompt prompt 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)
vi redraws the 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 Allows nested map sequences.
report 5
Displays a message on the status 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 [ window]
Number of lines to scroll with ^D and ^U
commands.
sections
(sect) SHNHH HU
Defines section delimiters for [[ and ]]
movement. The pairs of characters in the value
are the names of 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, and for the
<< and >> commands.
showmatch
(sm) nosm In vi, when ) or } is entered, cursor moves

论坛徽章:
0
272 [报告]
发表于 2008-06-11 16:29 |只看该作者
briefly to matching ( or {. (If no match, 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. For example, "OPEN MODE," or
"APPEND MODE."
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, vi
searches the file tags in the current directory
and /usr/lib/tags.)
tagstack tagstack Enables stacking of tag locations on a stack.
term Sets terminal type.
terse noterse Displays shorter error messages.
timeout (to) timeout Keyboard maps time out after 1 second.[A]
ttytype Sets terminal type. This is just another name
for term.
warn warn 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) nowa Allows saving to any file.

[A] When you have mappings of several keys (for example, :map zzz 3dw), you probably want to use
notimeout. Otherwise you need to type zzz within 1 second. When you have an insert mode mapping for a
cursor key (for example, :map! ^[OB ^[ja), you should use timeout. Otherwise, vi won't react to ESC until
you type another key.
C.2 nvi 1.79 Options
nvi 1.79 has a total of 78 options that affect its behavior. Table C.2 summarizes
the most important ones. Most options described in Table C.1 are not repeated
here.

Table C.2. nvi 1.79 Set Options

Option

Default

Description

论坛徽章:
0
273 [报告]
发表于 2008-06-11 16:29 |只看该作者
backup
A string describing a backup filename to use.
The current contents of a file are saved in
this file before writing the new data out. For
example, a value of "N%.bak" causes nvi to
include a version number at the end of the
file; version numbers are always
incremented.
cdpath
environment variable
CDPATH, or current
directory
A search path for the :cd command.
cedit
When the first character of this string is
entered on the colon command line, nvi
opens a new window on the command
history that you can then edit. Hitting
RETURN on any given line executes that line.
ESC is a good choice for this option. (Use ^V
^[ to enter it.)
comment nocomment
If the first non-empty line begins with /*,
//, or #, nvi skips the comment text before
displaying the file. This avoids displaying
long, boring legal notices.
directory(dir)
environment variable
TMPDIR, or /tmp
The directory where nvi puts its temporary
files.
extended noextended Searches use egrep-style extended regular
expressions.
filec
When the first character of this string is
entered on the colon command line, nvi
treats the blank delimited word in front of
the cursor as if it had an * appended to it
and does shell-style filename expansion. ESC
is a also good choice for this option. (Use ^V
^[ to enter it.) When this character is the
same as for the cedit option, command line
editing is performed only when the character
is entered as the first character on the colon
command line.
iclower noiclower
Make all regular expression searches case
insensitive, as long as the search pattern
contains no uppercase letters.
leftright noleftright Long lines scroll the screen left to right,
instead of wrapping.
lock lock
nvi attempts to get an exclusive lock on the
file. Editing a file that cannot be locked
creates a read-only session.
octal nooctal Displays unknown characters in octal,
instead of in hexadecimal.
path A colon-separated list of directories in which
nvi will look for the file to be edited.
recdir /var/tmp/vi.recover
The directory where recovery files are
stored.
ruler noruler Displays the row and column of the cursor.
searchincr nosearchincr Searches are done incrementally.

论坛徽章:
0
274 [报告]
发表于 2008-06-11 16:30 |只看该作者
secure nosecure
Turns off access to external programs via
text filtering (:r!, :w!), disables the vi mode
! and ^Z commands, and the ex mode !,
shell, stop, and suspend commands. Once
set, it cannot be changed.
shellmeta ~{[*?$`'"\
When any of these characters appear in a
filename argument to an ex command, the
argument is expanded by the program
named by the shell option.
showmode
(smd) noshowmode
Displays a string in the status line showing
the current mode. Displays an * if the file
has been modified.
sidescroll 16
The number of columns by which the screen
is shifted left or right when leftright is
true.
taglength(tl) 0
Defines number of characters that are
significant for tags. Default (zero) means
that all characters are significant.
tags (tag) tags /var/db/libc.tags
/sys/kern/tags
The list of possible tag files.
tildeop notildeop The ~ command takes an associated motion,
not just a preceding count.
wraplen(wl) 0
Identical to the wrapmargin option, except
that it specifies the number of characters
from the left margin at which the line will be
split. The value of wrapmargin overrides
wraplen.

C.3 elvis 2.0 Options
elvis 2.0 has a total of 144 options that affect its behavior. Table C.3 summarizes
the most important ones. Most options described in Table C.1 are not repeated
here.

Table C.3. elvis 2.0 Set Options
Option Default Description
autoiconify(aic) noautoiconify Iconify the old window when de-iconifying a new
one.
backup (bk) nobackup Make a backup file (xxx.bak) before writing the
current file out to disk.
binary (bin) The buffer's data is not text. This option is set
automatically.
boldfont
(xfb) The name of the bold font.
bufdisplay(bd) normal The default display mode for the buffer (hex,
html, man, normal, or syntax).
ccprg (cp) cc ($1?$12) The shell command for :cc.
commentfont
(cfont) The name of the font used for comments.

论坛徽章:
0
275 [报告]
发表于 2008-06-11 16:31 |只看该作者
directory(dir)
Where to store temporary files. The default is
system dependent.
display(mode) normal The name of current display mode, set by the
:display command.
elvispath(epath)
A list of directories in which to search for
configuration files. The default is system
dependent.
focusnew
(fn) focusnew Force keyboard focus into the new window.
functionfont
(ffont) The name of the font used for function names.
gdefault(gd) nogdefault Causes the substitute command to change all
instances.
home (home) $HOME The home directory for ~ in filenames.
italicfont
(xfi) The name of the italic font.
keywordfont(kfont) The name of the font used for reserved words.
lpcolumns(lpcols) 80 The width of a printer page; for :lpr.
lpcrlf (lpc) nolpcrlf The printer needs CR-LF for newline in the file;
for :lpr.
lpformfeed(lpff) nolpformfeed Send a form-feed after the last page; for :lpr.
lplines(lprows) 60 The length of a printer page; for :lpr.
lppaper(lpp) letter The paper size (letter, a4, ...) for PostScript
printers; for :lpr.
lpout (lpo) The printer file or filter, for :lpr. A typical value
might be !lpr. The default is system dependent.
lptype (lpt) dumb
The printer type, for :lpr. The value should be
one of: ps, ps2, epson, pana, ibm, hp, cr, bs, or
dumb.
lpwrap (lpw) lpwrap Simulate line-wrap; for :lpr.
makeprg (mp) make $1 The shell command for :make.
normalfont
(xfn) The name of the normal font.
otherfont
(ofont) The font used for other symbols.
prepfont(pfont) The font used for preprocessor commands.
ruler (ru) noruler Display the cursor's line and column.
safer
(trapunsafe) nosafer Be paranoid; use the :safer command to set
this, don't do it directly.
showmarkups(smu) noshowmarkups For the man and html modes, show the markup at
the cursor position, but not elsewhere.
sidescroll
(ss) 0 The sideways scrolling amount. Zero mimics vi,
making lines wrap.
stringfont(sfont) The font used for strings.
taglength 0 Defines number of characters that are significant

论坛徽章:
0
276 [报告]
发表于 2008-06-11 16:31 |只看该作者
(tl) for tags. Default (zero) means that all characters
are significant.
tags(tagpath) tags The list of possible tag files.
tagstack(tsk) tagstack Remember the origin of tag searches on a stack.
undolevels
(ul) 0
The number of undoable commands. Zero mimics
vi. You probably want to set this to a bigger
number.
variablefont
(vfont) The font used for variables.
warpback(wb) nowarpback Upon exit, move the pointer back to the xterm
which started elvis.
warpto (wt) don't
How ^W ^W forces pointer movement: don't for
no movement, scrollbar moves the pointer to
the scrollbar, origin moves the pointer to the
upper left corner, and corners moves it to the
corners furthest from and nearest to the current
cursor position. This forces the X display to pan,
to make sure the window is entirely onscreen.

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

论坛徽章:
0
277 [报告]
发表于 2008-06-11 16:32 |只看该作者
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.

论坛徽章:
0
278 [报告]
发表于 2008-06-11 16:32 |只看该作者
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,_,192255
A list of characters that can be included in
identifiers. Non-UNIX systems may have

论坛徽章:
0
279 [报告]
发表于 2008-06-11 16:33 |只看该作者
different default values.
iskeyword(isk)
@,48-57,_,192255
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.

论坛徽章:
0
280 [报告]
发表于 2008-06-11 16:33 |只看该作者
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.

C.5 vile 8.0 Options
vile 8.0 has a total of 92 options that affect its behavior. Table C.5 summarizes
the most important ones. Most options described in Table C.1 are not repeated
here.

Table C.5. vile 8.0 Set Options
Option Default Description
alt-tabpos noatp
Controls whether the cursor sits at the
left or right end of the whitespace
representing a TAB character.
animated animated
Automatically updates the contents of
scratch buffers when their contents
would change.
autobuffer (ab) autobuffer
Uses "most-recently-used" style
buffering; the buffers are sorted in
order of use. Otherwise, buffers remain
in the order in which they were edited.
autosave (as) noautosave
Automatic file saving. Writes the file
after every autosavecnt characters of
inserted text.
autosavecnt
(ascnt) 256 Specifies after how many inserted
characters automatic saves take place.
backspacelimit(bl) backspacelimit If disabled, then in insert mode you can
backspace past the point at which the
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP