Ubuntu vi 7.4 命令详解


vi 是功能强大的内置纯文本编辑器。

另请参阅: vim

基本用法     详细用法     快捷键

基本语法

编辑指定文件
vim [arguments] [file ..]
 
从 stdin 读取文本
vim [arguments] -
 
编辑 tag 定义的文件
vim [arguments] -t tag
 
采用第一个错误编辑文件
vim [arguments] -q [errorfile]
			

Arguments 自变量

参数 EN 解释 中文翻译 备注
-- Only file names after this 仅文件名在此之后
-v Vi mode (like "vi") Vi 模式 (像 vi)
-e Ex mode (like "ex") Ex 模式 (像 ex)
-E Improved Ex mode 改进的 Ex 模式
-s Silent (batch) mode (only for "ex") 静默 (批处理) 模式 (仅用于 ex)
-d Diff mode (like "vimdiff") Diff 模式 (像 vimdiff)
-y Easy mode (like "evim", modeless) 容易模式 (像 evim,无模式)
-R Readonly mode (like "view") 只读模式 (像 view)
-Z Restricted mode (like "rvim") 限定模式 (像 rvim)
-m Modifications (writing files) not allowed 不允许修改 (写入文件)
-M Modifications in text not allowed 不允许以文本方式修改
-b Binary mode 二进制模式
-l Lisp mode Lisp 模式
-C Compatible with Vi: 'compatible' 兼容 Vi:Compatible
-N Not fully Vi compatible: 'nocompatible' 完全不兼容 Vi:nocompatible
-V[N][fname] Be verbose [level N] [log messages to fname] 冗余 [level N] [日志信息到 fname]
-D Debugging mode 调试模式
-n No swap file, use memory only 不交换文件,只使用内存
-r List swap files and exit 列表交换文件并退出
-r (with file name) Recover crashed session 恢复崩溃会话
-L Same as -r 如同 -r
-A start in Arabic mode 以阿拉伯语模式启动
-H Start in Hebrew mode 以希伯来语模式启动
-F Start in Farsi mode 以波斯语模式启动
-T <terminal> Set terminal type to <terminal> 将终端类型设为 <terminal>
--not-a-term Skip warning for input/output not being a terminal 跳过输入/输出不是终端的警告
-u <vimrc> Use <vimrc> instead of any .vimrc 使用 <vimrc> 而不是任何 .vimrc
--noplugin Don't load plugin scripts 不加载插件脚本
-p[N] Open N tab pages (default: one for each file) 打开第 N 选项卡页面 (默认:每个文件一个)
-o[N] Open N windows (default: one for each file) 打开第 N 个窗口 (默认:每个文件一个)
-O[N] Like -o but split vertically 像 -o 但垂直分割
+ Start at end of file 从文件末尾开始
+<lnum> Start at line <lnum> 从第 <lnum> 行开始
--cmd <command> Execute <command> before loading any vimrc file 执行 <command> 在加载任何 vimrc 文件之前
-c <command> Execute <command> after loading the first file 执行 <command> 在加载首个文件之后
-S <session> Source file <session> after loading the first file 源文件 <session> 在加载首个文件之后
-s <scriptin> Read Normal mode commands from file <scriptin> 从 <scriptin> 文件读取正常模式命令
-w <scriptout> Append all typed commands to file <scriptout> 将所有键入命令追加到 <scriptout> 文件
-W <scriptout> Write all typed commands to file <scriptout> 将所有键入命令写入 <scriptout> 文件
-x Edit encrypted files 编辑加密文件
--startuptime <file> Write startup timing messages to <file> 将启动计时消息写入 <file>
-i <viminfo> Use <viminfo> instead of .viminfo 使用 <viminfo> 而不是 .viminfo
-h or --help Print Help (this message) and exit 打印帮助 (此消息) 并退出
--version Print version information and exit 打印版本信息并退出

基本用法

功能 命令 说明 备注
版本 vi --version 展示版本信息
帮助 vi -h 展示帮助信息
vi --help

快捷键

类别 操作 说明 备注
快捷键 /q 离开
/w 保存文件
末行 :q 离开
:w 保存文件
:wq 保存文件,离开
:set nu 展示行号
:set number

 

版权声明: 本文为独家原创稿件,版权归 乐数软件 ,未经许可不得转载。