vim 中文man页面

系统
Vim 是一个同 Vi 向上兼容的文本编辑器, 可以用来编辑任何 ASCII 文本, 特别适合用来编辑程序。

名称 (NAME)

vim - Vi IMproved, 一个程序员的文本编辑器

总览 (SYNOPSIS)


vim [options] [file ..]
vim [options] -
vim [options] -t tag
vim [options] -q [errorfile]


ex
view
gvim gview
rvim rview rgvim rgview

描述 (DESCRIPTION)

Vim 是一个同 Vi 向上兼容的文本编辑器, 可以用来编辑任何 ASCII 文本, 特别适合用来编辑程序。

它对 Vi 作了许多增强: 多层撤销, 多窗口, 多缓冲区(buffer), 高亮度语法显示, 命令行编辑, 文件名匹配, 在线帮助, 可视选定, 等等。 用 ":help vi_diff.txt" 看 Vim 和 Vi 的差别的摘要。

在运行 Vim 的时候可以用 ":help" 命令获得很多帮助。参考下面的在线帮助一节。

一般可用

       vim file
 

命令打开 Vim 来编辑一个文件。 概括的说, 可以用

       vim [options] [filelist]
 

命令来运行 Vim 。 如果没有文件名, 编辑器就会打开一个空的缓冲区。否则就会用下面四个中的一个来选择要编辑的文件。

file ..
文件名列表。 ***个会作为当前文件读入缓冲区, 光标会停在缓冲区的***行。你可以用 ":next" 命令转到其它的文件。 如果要编辑一个以 "-" 开头的文件, 在文件列表前面加上 "--"。
-
从标准输入读取被编辑的文件。 从标准错误输出(应该是个终端)读入命令。
-t {tag}
被编辑的文件和光标的初始位置由标记(tag)决定, 标记有点像一种 goto 标签 (goto label)。在标记文件中找到标记, 相应的文件成为当前文件, 相应的命令被执行。 这种方式常用于 C 程序, 标记就是函数名, 当前文件就是包含那个函数的文件, 光标停留在函数的开始处。见 ":help tag-commands"。
-q [errorfile]
运行时进入快速修复模式。读取 [errorfile] 文件并显示***个错误。 如果没有 [errorfile] 文件,文件名由 'errorfile' 选项决定 (在 Amiga 为 "AztecC.Err", 在其他系统中为 "errors.vim")。可以用 ":cn" 命令条到其它错误处。见 ":help quickfix"。

Vim 会根据不同命令有不同的表现, 尽管它们可能是用一个可执行文件。

vim
正常模式, 所有都是默认状态。
ex
以 Ex 模式运行。 用 ":vi" 命令进入正常模式。 也可以加上 "-e" 选项进入此模式。
view
以只读模式运行。 你被禁止写文件。 也可以加上 "-R" 选项进入此模式。
gvim gview
GUI 版本。开启一个新的窗口。 也可以加上 "-g" 选项进入此模式。
rvim rview rgvim rgview
同上面的相同, 只是加上了限制, 不能运行 shell 程序, 也不能暂停 Vim 。 也可以加上 "-Z" 选项进入此模式。

选项 (OPTIONS)

所有选项都可以以任何顺序出现, 可以在文件名前, 也可以在文件名后。没有参数的选项可以出现在一个 "-" 后面。

+[num]
对于***个文件, 光标会停在第 "num" 行。 如果没有 "num" , 则光标会停在***一行。
+/{pat}
对于***个文件, 光标会停在 {pat} ***次出现的地方。 搜寻模式见 ":help search-pattern"。
+{command}
-c {command}
读入***个文件后会执行 {command} 命令。 {command} 应为 Ex 命令。如果 {command} 中包含有空格, 必须用双引号括住(这个取决于所用的 shell)。例: Vim "+set si" main.c
注意: 你可以用最多 10 个 "+" 或者 "-c" 命令。
-b
二进制模式。设置一些选项, 这样就可以用来编辑二进制和可执行文件了。
-C
兼容。 设置 'compatible' 选项。 这样就算存在 .vimrc 文件 Vim 也会基本上象 Vi 一样了。
-d {device}
它开 {device} 用作终端, 只在 Amiga 下。例: "-d con:20/30/600/150".
-e
以 Ex 模式运行 Vim , 就像运行 "ex" 一样。
-f
前台运行。 对于 GUI 版本, Vim 不会同运行它的 shell 分离。在 Amiga 中, Vim 不会重新启动来开启一个新窗口。这个选项会用在当 Vim 被另外一个程序执行, 并且这个程序想等编辑动作结束后再运行的时候(如 mail)。 在 Amiga 上 ":sh" 和 ":!" 不会起作用。
-F
如果 Vim 编译时加入了对从右到左书写的文件 FKMAP 以及 Farsi 键盘映射的支持, Vim 会以 Farsi 模式运行, 比如设置 'fkmap' 和 'rightleft' 选项。不然 Vim 会显示一条错误信息并终止。
-g
如果 Vim 编译时加入 GUI 支持, 会开启 GUI, 不然 Vim 会显示一条错误信息并终止。
-h
Vim 显示命令行参数和选项的帮助, 然后终止。
-H
如果 Vim 编译时加入了对从右到左书写的文件 RIGHTLEFT 以及 Hebrew 键盘映射的支持, Vim 会以 Hebrew 模式运行, 比如设置 'hkmap' 和 'rightleft' 选项。不然 Vim 会显示一条错误信息并终止。
-i {viminfo}
准许使用 viminfo 文件, 这个选项设置使用的文件名, 默认的是 "~/.viminfo"。 用 "NONE" 文件名也可以跳过使用 .viminfo 文件。
-L
同 -r 一样。
-l
Lisp 模式。打开 'lisp' 和 'showmatch' 选项。
-m
禁止修改文件。 重置 'write' 选项, 这用就不能写文件了。
-N
非兼容模式。 重置 'compatible' 选项。 这样 Vim 会表现得更好, 就算 .vimrc 文件不存在也会同 Vi 不兼容。
-n
禁止交换文件, 这样在崩溃后就不能恢复文件了。 对于编辑在很慢的媒体中的文件很有好处(比如软盘), 也可以用 ":set uc=0" 禁止交换, 用 ":set uc=200" 开启交换。
-o[N]
打开 N 个窗口。如果没有 N, 为每个文件开一个窗口。
-R
只读模式。设置 'readonly' 选项。 你人染可以编辑缓冲区, 但是不能重写文件。 如果你要重写文件,必须在 Ex 命令中用惊叹号, 比如 ":w!"。
 -R 选项包含有 -n 选项(见下)。 见 ":help 'readonly'"。
-r
列出交换文件, 显示关于恢复文件的信息。
-r {file}
恢复模式。交换文件是用来恢复在编辑过程中崩溃了的文件。 交换文件名是被编辑文件名后面加上 ".swp"。见 ":help recovery"。
-s
安静模式。 只在用 "Ex" 启动或者用了 "-e" 选项才有用。
-s {scriptin}
读入脚本文件 {scriptin} 。 文件里的字符就像你直接输入一样的, 也可以用 ":source! {scriptin}" 命令实现这个功能。 如果在编辑器结束前就读到了文件尾,就接着从键盘读入。
-T {terminal}
告诉 Vim 你用的终端的名字, 只有当不能自动确定不了时候才这样。 它必须是 Vim (builtin) 能辨认的终端或者是在 termcap 或者 terminfo 文件中定义了的。
-u {vimrc}
用 {vimrc} 文件里的命令来初始化, 跳过所有其它的初始化, 用这个来编辑特殊类型的文件。也可以用 "NONE" 来跳过所有初始化。 在 vim 中用 ":help initialization" 查看更多信息。
-U {gvimrc}
用 {gvimrc} 文件里的命令来初始化 GUI, 跳过所有其它的 GUI 初始化, 也可以用 "NONE" 来跳过所有 GUI 初始化。 在 vim 中用 ":help gui-init" 查看更多信息。
-V
冗长显示。 显示执行初始化代码和读入的文件, 并且写 viminfo 文件。
-v
以 Vi 模式运行 Vim , 就像运行 "vi" 一样, 只有运行 "ex" 时才有用。
-w {scriptout}
所有在 Vim 退出前你键入的字符都会被存入 {scriptout} 文件。 这用来创建一个脚本文件, 你可以用 "vim -s" 和 ":source!" 来使用。 如果 {scriptout} 存在, 会把字符追加到后面。
-W {scriptout}
同 -w 一样, 但是是覆盖原来的文件。
-x
写文件时加密。 会提示你输入密码。
-Z
受限模式。 同运行以 "r" 开始的程序同效。
--
表明选项结束。 在此之后的参数都会被认为是文件名, 可以用这个来编辑一个以 '-' 开头的文件。

在线帮助 (ON-LINE HELP)

Vim 中键入 ":help" 来获得帮助。用 ":help subject" 来获得关于一个特定主题的帮助。例如用 ":help ZZ" 来获得关于 "ZZ" 的帮助。用 <Tab> 和 CTRL-D 来完成主题(":help cmdline-completion")。可以用标记从一个地方跳到另一个地方(有点像超文本连接, 见 ":help")。所有的文档都可以这样来浏览, 比如 ":help syntax.txt"。

文件 (FILES)

/usr/share/vim/vim56/doc/*.txt
Vim 文档文件。用 ":help doc-file-list" 获得完整的列表。
/usr/share/vim/vim56/doc/tags
在文档文件中查找信息用的标签文件。
/usr/share/vim/vim56/syntax/syntax.vim
系统语法初始化文件。
/usr/share/vim/vim56/syntax/*.vim
各种语言的语法文件。
/usr/share/vim/vimrc
系统 Vim 初始化文件。
/usr/share/vim/gvimrc
系统 gvim 初始化文件。
/usr/share/vim/vim56/optwin.vim
":options" 命令所用的脚本文件, 这是个查看和设置选项的很好的办法。
/usr/share/vim/vim56/menu.vim
gvim 的系统菜单初始化文件。
/usr/share/vim/vim56/bugreport.vim
用来生成错误报告的脚本文件, 见 ":help bugs"。
/usr/share/vim/vim56/filetype.vim
根据文件名来判定文件类型的脚本文件, 见 ":help 'filetype'"。
/usr/share/vim/vim56/scripts.vim
根据文件内容来判定文件类型的脚本文件, 见 ":help 'filetype'"。

***信息参见 VIM 主页:
<URL:http://www.vim.org/>

参见 (SEE ALSO)

vimtutor(1)

#p#

NAME

vim - Vi IMproved, a programmers text editor

SYNOPSIS


vim [options] [file ..]
vim [options] -
vim [options] -t tag
vim [options] -q [errorfile]


ex
view
gvim gview evim eview
rvim rview rgvim rgview

DESCRIPTION

Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing programs.

There are a lot of enhancements above Vi: multi level undo, multi windows and buffers, syntax highlighting, command line editing, filename completion, on-line help, visual selection, etc.. See ":help vi_diff.txt" for a summary of the differences between Vim and Vi.

While running Vim a lot of help can be obtained from the on-line help system, with the ":help" command. See the ON-LINE HELP section below.

Most often Vim is started to edit a single file with the command

       vim file
 

More generally Vim is started with:

       vim [options] [filelist]
 

If the filelist is missing, the editor will start with an empty buffer. Otherwise exactly one out of the following four may be used to choose one or more files to be edited.

file ..
A list of filenames. The first one will be the current file and read into the buffer. The cursor will be positioned on the first line of the buffer. You can get to the other files with the ":next" command. To edit a file that starts with a dash, precede the filelist with "--".
-
The file to edit is read from stdin. Commands are read from stderr, which should be a tty.
-t {tag}
The file to edit and the initial cursor position depends on a "tag", a sort of goto label. {tag} is looked up in the tags file, the associated file becomes the current file and the associated command is executed. Mostly this is used for C programs, in which case {tag} could be a function name. The effect is that the file containing that function becomes the current file and the cursor is positioned on the start of the function. See ":help tag-commands".
-q [errorfile]
Start in quickFix mode. The file [errorfile] is read and the first error is displayed. If [errorfile] is omitted, the filename is obtained from the 'errorfile' option (defaults to "AztecC.Err" for the Amiga, "errors.err" on other systems). Further errors can be jumped to with the ":cn" command. See ":help quickfix".

Vim behaves differently, depending on the name of the command (the executable may still be the same file).

vim
The "normal" way, everything is default.
ex
Start in Ex mode. Go to Normal mode with the ":vi" command. Can also be done with the "-e" argument.
view
Start in read-only mode. You will be protected from writing the files. Can also be done with the "-R" argument.
gvim gview
The GUI version. Starts a new window. Can also be done with the "-g" argument.
evim eview
The GUI version in easy mode. Starts a new window. Can also be done with the "-y" argument.
rvim rview rgvim rgview
Like the above, but with restrictions. It will not be possible to start shell commands, or suspend Vim. Can also be done with the "-Z" argument.

OPTIONS

The options may be given in any order, before or after filenames. Options without an argument can be combined after a single dash.

+[num]
For the first file the cursor will be positioned on line "num". If "num" is missing, the cursor will be positioned on the last line.
+/{pat}
For the first file the cursor will be positioned on the first occurrence of {pat}. See ":help search-pattern" for the available search patterns.
+{command}
-c {command}
{command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If the {command} contains spaces it must be enclosed in double quotes (this depends on the shell that is used). Example: Vim "+set si" main.c
Note: You can use up to 10 "+" or "-c" commands.
-S {file}
{file} will be sourced after the first file has been read. This is equivalent to -c "source {file}". {file} cannot start with '-'. If {file} is omitted "Session.vim" is used (only works when -S is the last argument).
--cmd {command}
Like using "-c", but the command is executed just before processing any vimrc file. You can use up to 10 of these commands, independently from "-c" commands.
-A
If Vim has been compiled with ARABIC support for editing right-to-left oriented files and Arabic keyboard mapping, this option starts Vim in Arabic mode, i.e. 'arabic' is set. Otherwise an error message is given and Vim aborts.
-b
Binary mode. A few options will be set that makes it possible to edit a binary or executable file.
-C
Compatible. Set the 'compatible' option. This will make Vim behave mostly like Vi, even though a .vimrc file exists.
-d
Start in diff mode. There should be two or three file name arguments. Vim will open all the files and show differences between them. Works like vimdiff(1).
-d {device}
Open {device} for use as a terminal. Only on the Amiga. Example: "-d con:20/30/600/150".
-D
Debugging. Go to debugging mode when executing the first command from a script.
-e
Start Vim in Ex mode, just like the executable was called "ex".
-E
Start Vim in improved Ex mode, just like the executable was called "exim".
-f
Foreground. For the GUI version, Vim will not fork and detach from the shell it was started in. On the Amiga, Vim is not restarted to open a new window. This option should be used when Vim is executed by a program that will wait for the edit session to finish (e.g. mail). On the Amiga the ":sh" and ":!" commands will not work.
--nofork
Foreground. For the GUI version, Vim will not fork and detach from the shell it was started in.
-F
If Vim has been compiled with FKMAP support for editing right-to-left oriented files and Farsi keyboard mapping, this option starts Vim in Farsi mode, i.e. 'fkmap' and 'rightleft' are set. Otherwise an error message is given and Vim aborts.
-g
If Vim has been compiled with GUI support, this option enables the GUI. If no GUI support was compiled in, an error message is given and Vim aborts.
-h
Give a bit of help about the command line arguments and options. After this Vim exits.
-H
If Vim has been compiled with RIGHTLEFT support for editing right-to-left oriented files and Hebrew keyboard mapping, this option starts Vim in Hebrew mode, i.e. 'hkmap' and 'rightleft' are set. Otherwise an error message is given and Vim aborts.
-i {viminfo}
When using the viminfo file is enabled, this option sets the filename to use, instead of the default "~/.viminfo". This can also be used to skip the use of the .viminfo file, by giving the name "NONE".
-L
Same as -r.
-l
Lisp mode. Sets the 'lisp' and 'showmatch' options on.
-m
Modifying files is disabled. Resets the 'write' option. You can still modify the buffer, but writing a file is not possible.
-M
Modifications not allowed. The 'modifiable' and 'write' options will be unset, so that changes are not allowed and files can not be written. Note that these options can be set to enable making modifications.
-N
No-compatible mode. Reset the 'compatible' option. This will make Vim behave a bit better, but less Vi compatible, even though a .vimrc file does not exist.
-n
No swap file will be used. Recovery after a crash will be impossible. Handy if you want to edit a file on a very slow medium (e.g. floppy). Can also be done with ":set uc=0". Can be undone with ":set uc=200".
-nb
Become an editor server for NetBeans. See the docs for details.
-o[N]
Open N windows stacked. When N is omitted, open one window for each file.
-O[N]
Open N windows side by side. When N is omitted, open one window for each file.
-R
Read-only mode. The 'readonly' option will be set. You can still edit the buffer, but will be prevented from accidently overwriting a file. If you do want to overwrite a file, add an exclamation mark to the Ex command, as in ":w!". The -R option also implies the -n option (see below). The 'readonly' option can be reset with ":set noro". See ":help 'readonly'".
-r
List swap files, with information about using them for recovery.
-r {file}
Recovery mode. The swap file is used to recover a crashed editing session. The swap file is a file with the same filename as the text file with ".swp" appended. See ":help recovery".
-s
Silent mode. Only when started as "Ex" or when the "-e" option was given before the "-s" option.
-s {scriptin}
The script file {scriptin} is read. The characters in the file are interpreted as if you had typed them. The same can be done with the command ":source! {scriptin}". If the end of the file is reached before the editor exits, further characters are read from the keyboard.
-T {terminal}
Tells Vim the name of the terminal you are using. Only required when the automatic way doesn't work. Should be a terminal known to Vim (builtin) or defined in the termcap or terminfo file.
-u {vimrc}
Use the commands in the file {vimrc} for initializations. All the other initializations are skipped. Use this to edit a special kind of files. It can also be used to skip all initializations by giving the name "NONE". See ":help initialization" within vim for more details.
-U {gvimrc}
Use the commands in the file {gvimrc} for GUI initializations. All the other GUI initializations are skipped. It can also be used to skip all GUI initializations by giving the name "NONE". See ":help gui-init" within vim for more details.
-V[N]
Verbose. Give messages about which files are sourced and for reading and writing a viminfo file. The optional number N is the value for 'verbose'. Default is 10.
-v
Start Vim in Vi mode, just like the executable was called "vi". This only has effect when the executable is called "ex".
-w {scriptout}
All the characters that you type are recorded in the file {scriptout}, until you exit Vim. This is useful if you want to create a script file to be used with "vim -s" or ":source!". If the {scriptout} file exists, characters are appended.
-W {scriptout}
Like -w, but an existing file is overwritten.
-x
Use encryption when writing files. Will prompt for a crypt key.
-X
Don't connect to the X server. Shortens startup time in a terminal, but the window title and clipboard will not be used.
-y
Start Vim in easy mode, just like the executable was called "evim" or "eview". Makes Vim behave like a click-and-type editor.
-Z
Restricted mode. Works like the executable starts with "r".
--
Denotes the end of the options. Arguments after this will be handled as a file name. This can be used to edit a filename that starts with a '-'.
--echo-wid
GTK GUI only: Echo the Window ID on stdout
--help
Give a help message and exit, just like "-h".
--literal
Take file name arguments literally, do not expand wildcards. Not needed on Unix, the shell expand wildcards.
--noplugin
Skip loading plugins. Implied by -u NONE.
--remote
Connect to a Vim server and make it edit the files given in the rest of the arguments. If no server is found a warning is given and the files are edited in the current Vim.
--remote-expr {expr}
Connect to a Vim server, evaluate {expr} in it and print the result on stdout.
--remote-send {keys}
Connect to a Vim server and send {keys} to it.
--remote-silent
As --remote, but without the warning when no server is found.
--remote-wait
As --remote, but Vim does not exit until the files have been edited.
--remote-wait-silent
As --remote-wait, but without the warning when no server is found.
--serverlist
List the names of all Vim servers that can be found.
--servername {name}
Use {name} as the server name. Used for the current Vim, unless used with a --remote argument, then it's the name of the server to connect to.
--socketid {id}
GTK GUI only: Use the GtkPlug mechanism to run gvim in another window.
--version
Print version information and exit.

ON-LINE HELP

Type ":help" in Vim to get started. Type ":help subject" to get help on a specific subject. For example: ":help ZZ" to get help for the "ZZ" command. Use <Tab> and CTRL-D to complete subjects (":help cmdline-completion"). Tags are present to jump from one place to another (sort of hypertext links, see ":help"). All documentation files can be viewed in this way, for example ":help syntax.txt".

FILES

/usr/share/vim/vim63/doc/*.txt
The Vim documentation files. Use ":help doc-file-list" to get the complete list.
/usr/share/vim/vim63/doc/tags
The tags file used for finding information in the documentation files.
/usr/share/vim/vim63/syntax/syntax.vim
System wide syntax initializations.
/usr/share/vim/vim63/syntax/*.vim
Syntax files for various languages.
/usr/share/vim/vimrc
System wide Vim initializations.
/usr/share/vim/gvimrc
System wide gvim initializations.
/usr/share/vim/vim63/optwin.vim
Script used for the ":options" command, a nice way to view and set options.
/usr/share/vim/vim63/menu.vim
System wide menu initializations for gvim.
/usr/share/vim/vim63/bugreport.vim
Script to generate a bug report. See ":help bugs".
/usr/share/vim/vim63/filetype.vim
Script to detect the type of a file by its name. See ":help 'filetype'".
/usr/share/vim/vim63/scripts.vim
Script to detect the type of a file by its contents. See ":help 'filetype'".
/usr/share/vim/vim63/*.ps
Files used for PostScript printing.

For recent info read the VIM home page:
<URL:http://www.vim.org/>

SEE ALSO

vimtutor(1)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-15 16:06:08

vim中文man

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man

2011-08-25 15:49:02

freopen中文man

2011-08-25 16:00:56

fflush中文man

2011-08-25 16:08:55

fsetpos中文man

2011-08-25 15:33:18

exit中文man

2011-08-24 17:19:00

raw中文man

2011-08-25 10:55:37

services中文man

2011-08-25 09:35:26

units中文man

2011-08-24 13:57:35

DECLARE中文man

2011-08-11 15:28:43

ali中文man

2011-08-23 17:18:44

umount中文man

2011-08-23 17:24:11

userdel中文man

2011-08-23 17:33:22

rdev中文man

2011-08-23 18:05:21

ABORT中文man
点赞
收藏

51CTO技术栈公众号