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

詳細用法

命令模式

功能 操作 說明 備注
返迴 Esc 鍵 返迴命令模式
保存 ZZ 保存文件,退齣 vi 返迴 shell

輸入模式

功能 操作 說明 備注
插入 i 從當前光標處開始插入

末行模式

功能 操作 說明 備注
離開 :q 離開
保存 :w 保存文件
:wq 保存文件,離開
行號 :set nu 展示行號
:set number
搜索 :set ignorecase 忽略大小寫
:set incsearch 逐字符高亮

 

版權聲明: 本文為獨傢原創稿件,版權歸 樂數軟件 ,未經許可不得轉載。