快速參考

Nvim 的 :help 頁面,由 產生,來源為 原始碼,並使用 tree-sitter-vimdoc 解析器。


快速參考指南

目錄
標籤 主題 標籤 主題
Q_ct 幫助檔案列表 Q_re 重複指令 Q_lr 移動:左右 Q_km 按鍵映射 Q_ud 移動:上下 Q_ab 縮寫 Q_tm 移動:文字物件 Q_op 選項 Q_pa 移動:模式搜尋 Q_ur 復原/重做指令 Q_ma 移動:標記 Q_et 外部指令 Q_vm 移動:其他 Q_qf 快速修正指令 Q_ta 移動:使用標籤 Q_vc 各式指令 Q_sc 捲動 Q_ce Ex:命令列編輯 Q_in 插入:插入文字 Q_ra Ex:範圍 Q_ai 插入:按鍵 Q_ex Ex:特殊字元 Q_ss 插入:特殊按鍵 Q_st 啟動 Vim Q_di 插入:雙字符 Q_ed 編輯檔案 Q_si 插入:特殊插入 Q_fl 使用引數列表 Q_de 變更:刪除文字 Q_wq 寫入和離開 Q_cm 變更:複製和移動 Q_ac 自動指令 Q_ch 變更:變更文字 Q_wi 多視窗指令 Q_co 變更:複雜 Q_bu 緩衝區列表指令 Q_vi 可視模式 Q_sy 語法高亮 Q_to 文字物件 Q_gu GUI 指令 Q_fo 折疊

Q_lr 左右移動

N 用於表示可以在指令前給定的可選計數。
h N h 向左 (亦可使用: CTRL-H, <BS>, 或 <Left> 鍵) l N l 向右 (亦可使用: <Space><Right> 鍵) 0 0 到行首字元 (亦可使用: <Home> 鍵) ^ ^ 到行首非空白字元 $ N $ 到下一個 EOL (行尾) 位置 (亦可使用: <End> 鍵) g0 g0 到螢幕行首字元 (當行換行時與 "0" 不同) g^ g^ 到螢幕行首非空白字元 (當行換行時與 "^" 不同) g$ N g$ 到螢幕行尾字元 (當行換行時與 "$" 不同) gm gm 到螢幕行中間 gM gM 到行中間 bar N | 到第 N 欄 (預設: 1) f N f{char} 到右邊第 N 個 {char} F N F{char} 到左邊第 N 個 {char} t N t{char} 到右邊第 N 個 {char} 之前 T N T{char} 到左邊第 N 個 {char} 之前 ; N ; 重複上次的 "f", "F", "t", 或 "T" N 次 , N , 重複上次的 "f", "F", "t", 或 "T" N 次,方向相反

Q_ud 上下移動

k N k 向上 N 行 (亦可使用: CTRL-P<Up>) j N j 向下 N 行 (亦可使用: CTRL-J, CTRL-N, <NL>, 和 <Down>) - N - 向上 N 行,到第一個非空白字元 + N + 向下 N 行,到第一個非空白字元 (亦可使用: CTRL-M<CR>) _ N _ 向下 N-1 行,到第一個非空白字元 G N G 到第 N 行 (預設: 最後一行),到第一個非空白字元 gg N gg 到第 N 行 (預設: 第一行),到第一個非空白字元 N% N % 到檔案的第 N 百分比處; 必須給定 N,否則為 % 指令 gk N gk 向上 N 個螢幕行 (當行換行時與 "k" 不同) gj N gj 向下 N 個螢幕行 (當行換行時與 "j" 不同)

Q_tm 文字物件移動

w N w 向前 N 個字 W N W 向前 N 個以空白分隔的 WORD e N e 向前到第 N 個字的結尾 E N E 向前到第 N 個以空白分隔的 WORD 的結尾 b N b 向後 N 個字 B N B 向後 N 個以空白分隔的 WORD ge N ge 向後到第 N 個字的結尾 gE N gE 向後到第 N 個以空白分隔的 WORD 的結尾
) N ) 向前 N 個句子 ( N ( 向後 N 個句子 } N } 向前 N 個段落 { N { 向後 N 個段落 ]] N ]] 向前 N 個章節,到章節開始處 [[ N [[ 向後 N 個章節,到章節開始處 ][ N ][ 向前 N 個章節,到章節結尾處 [] N [] 向後 N 個章節,到章節結尾處 [( N [( 向後 N 次到未關閉的 '(' [{ N [{ 向後 N 次到未關閉的 '{' [m N [m 向後 N 次到方法開始處 (適用於 Java) [M N [M 向後 N 次到方法結束處 (適用於 Java) ]) N ]) 向前 N 次到未關閉的 ')' ]} N ]} 向前 N 次到未關閉的 '}' ]m N ]m 向前 N 次到方法開始處 (適用於 Java) ]M N ]M 向前 N 次到方法結束處 (適用於 Java) [# N [# 向後 N 次到未關閉的 "#if" 或 "#else" ]# N ]# 向前 N 次到未關閉的 "#else" 或 "#endif" [star N [* 向後 N 次到註解 "/*" 開始處 ]star N ]* 向前 N 次到註解 "*/" 結束處

Q_pa 模式搜尋

/ N /{pattern}[/[offset]]<CR> 向前搜尋第 N 個 {pattern} 的出現 ? N ?{pattern}[?[offset]]<CR> 向後搜尋第 N 個 {pattern} 的出現 /<CR> N /<CR> 重複上次搜尋,向前方向 ?<CR> N ?<CR> 重複上次搜尋,向後方向 n N n 重複上次搜尋 N N N 重複上次搜尋,方向相反 star N * 向前搜尋游標下的識別字 # N # 向後搜尋游標下的識別字 gstar N g* 類似 "*",但也尋找部分匹配 g# N g# 類似 "#",但也尋找部分匹配 gd gd 跳到游標下識別字的本地宣告 gD gD 跳到游標下識別字的全局宣告
pattern 搜尋模式中的特殊字元
意義 magic nomagic
匹配任何單一字元 . \. 匹配行首 ^ ^ 匹配 <EOL> $ $ 匹配字首 \< \< 匹配字尾 \> \> 匹配範圍內的單一字元 [a-z] \[a-z] 匹配範圍外的單一字元 [^a-z] \[^a-z] 匹配識別字元 \i \i 同上,但不包括數字 \I \I 匹配關鍵字元 \k \k 同上,但不包括數字 \K \K 匹配檔名字元 \f \f 同上,但不包括數字 \F \F 匹配可列印字元 \p \p 同上,但不包括數字 \P \P 匹配空白字元 \s \s 匹配非空白字元 \S \S
匹配 <Esc> \e \e 匹配 <Tab> \t \t 匹配 <CR> \r \r 匹配 <BS> \b \b
匹配 0 個或更多個前面的原子 * \* 匹配 1 個或更多個前面的原子 \+ \+ 匹配 0 個或 1 個前面的原子 \= \= 匹配 2 到 5 個前面的原子 \{2,5} \{2,5} 分隔兩個替代方案 \| \| 將模式分組為一個原子 \(\) \(\)
search-offset 搜尋指令後允許的偏移
[數字] [數字] 向下 [數字] 行,在第一欄 +[數字] 向下 [數字] 行,在第一欄 -[數字] 向上 [數字] 行,在第一欄 e[+數字] 匹配結束處右邊 [數字] 個字元 e[-數字] 匹配結束處左邊 [數字] 個字元 s[+數字] 匹配開始處右邊 [數字] 個字元 s[-數字] 匹配開始處左邊 [數字] 個字元 b[+數字] 與上面的 s[+數字] 相同 (助記:begin) b[-數字] 與上面的 s[-數字] 相同 (助記:begin) ;{search-command} 接著執行 {search-command}

Q_ma 標記和移動

m m{a-zA-Z} 以標記 {a-zA-Z} 標記目前位置 `a{a-z} 跳到目前檔案內標記 {a-z} 的位置 `A{A-Z} 跳到任何檔案內標記 {A-Z} 的位置 `0{0-9} 跳到上次 Vim 離開的位置 `` `` 跳到上次跳躍前的位置 `quote" 跳到上次編輯此檔案的位置 `[[ 跳到上次操作或貼上的文字開始處 `]] 跳到上次操作或貼上的文字結束處 `<< 跳到 (上一個) 可視區域的開始處 `>> 跳到 (上一個) 可視區域的結束處 `.. 跳到此檔案最後一次變更的位置 ' '{a-zA-Z0-9[]'"<>.} 相同,但在該行的第一個非空白字元上 :marks :marks 列印有效的標記 CTRL-O N CTRL-O 跳到跳躍列表中的第 N 個較舊位置 CTRL-I N CTRL-I 跳到跳躍列表中的第 N 個較新位置 :ju :ju[mps] 列印跳躍列表

Q_vm 各式移動

% % 找到此行中的下一個大括號、中括號、註解或 "#if"/"#else"/"#endif",並跳到它的匹配項 H N H 跳到視窗中的第 N 行,到第一個非空白字元 M M 跳到視窗中間行,到第一個非空白字元 L N L 跳到從底部算起的第 N 行,到第一個非空白字元
go N 前往緩衝區的第 N 個位元組 :go :[範圍]go[to] [偏移量] 前往緩衝區的第 [偏移量] 個位元組

Q_ta 使用標籤

:ta :ta[g][!] {標籤} 跳到標籤 {標籤} :ta :[數量]ta[g][!] 跳到標籤列表中的第 [數量] 個較新的標籤 CTRL-] CTRL-] 跳到游標下的標籤,除非已進行變更 :ts :ts[elect][!] [標籤] 列出匹配的標籤並選擇一個跳轉 :tjump :tj[ump][!] [標籤] 跳到標籤 [標籤],或在有多個匹配項時從列表中選擇 :ltag :lt[ag][!] [標籤] 跳到標籤 [標籤],並將匹配的標籤添加到位置列表中
:tags :tags 列印標籤列表 CTRL-T N CTRL-T 從標籤列表中的第 N 個較舊的標籤跳回 :po :[數量]po[p][!] 從標籤列表中的第 [數量] 個較舊的標籤跳回 :tnext :[數量]tn[ext][!] 跳到第 [數量] 個下一個匹配的標籤 :tp :[數量]tp[revious][!] 跳到第 [數量] 個上一個匹配的標籤 :tr :[數量]tr[ewind][!] 跳到第 [數量] 個匹配的標籤 :tl :tl[ast][!] 跳到最後一個匹配的標籤
:ptag :pt[ag] {標籤} 開啟預覽視窗以顯示標籤 {標籤} CTRL-W_} CTRL-W } 類似於 CTRL-] 但在預覽視窗中顯示標籤 :pts :pts[elect] 類似於 ":tselect" 但在預覽視窗中顯示標籤 :ptjump :ptj[ump] 類似於 ":tjump" 但在預覽視窗中顯示標籤 :pclose :pc[lose] 關閉標籤預覽視窗 CTRL-W_z CTRL-W z 關閉標籤預覽視窗

Q_sc 捲動

CTRL-E N CTRL-E 視窗向下移動 N 行 (預設值: 1) CTRL-D N CTRL-D 視窗向下移動 N 行 (預設值: 1/2 視窗) CTRL-F N CTRL-F 視窗向前(向下)移動 N 頁 CTRL-Y N CTRL-Y 視窗向上移動 N 行 (預設值: 1) CTRL-U N CTRL-U 視窗向上移動 N 行 (預設值: 1/2 視窗) CTRL-B N CTRL-B 視窗向後(向上)移動 N 頁 z<CR> z<CR> 或 zt 重繪,目前行在視窗頂端 z. z. 或 zz 重繪,目前行在視窗中心 z- z- 或 zb 重繪,目前行在視窗底部
只有在 'wrap' 關閉時才有效: zh N zh 螢幕向右捲動 N 個字元 zl N zl 螢幕向左捲動 N 個字元 zH N zH 螢幕向右捲動半個螢幕寬度 zL N zL 螢幕向左捲動半個螢幕寬度

Q_in 插入文字

a N a 在游標後附加文字 (N 次) A N A 在行尾附加文字 (N 次) i N i 在游標前插入文字 (N 次) (也包括:<Insert>) I N I 在行的第一個非空白字元前插入文字 (N 次) gI N gI 在第 1 欄插入文字 (N 次) o N o 在目前行下方開啟新行,附加文字 (N 次) O N O 在目前行上方開啟新行,附加文字 (N 次) :startinsert :star[tinsert][!] 開始插入模式,使用 [!] 時附加 :startreplace :startr[eplace][!] 開始取代模式,使用 [!] 時位於 EOL
在視覺區塊模式中: v_b_I I 在所有選定行的前面插入相同的文字 v_b_A A 在所有選定行的後面附加相同的文字

Q_ai 插入模式按鍵

insert-index 插入模式指令的字母索引
離開插入模式: i_<Esc> <Esc> 結束插入模式,返回一般模式 i_CTRL-C CTRL-C 類似於 <Esc>,但不使用縮寫 i_CTRL-O CTRL-O {指令} 執行 {指令} 並返回插入模式
移動: i_<Up> 游標按鍵向左/向右/向上/向下移動游標 i_<S-Left> 向左/向右移動一個單字 i_<S-Up> 向上/向下移動一個畫面 i_<End> <End> 將游標移到該行最後一個字元之後 i_<Home> <Home> 將游標移到該行的第一個字元

Q_ss 插入模式中的特殊按鍵

i_CTRL-V CTRL-V {字元}.. 逐字插入字元,或輸入十進制位元組值 i_<NL> <NL><CR>CTRL-MCTRL-J 開始新行 i_CTRL-E CTRL-E 插入游標下方字元 i_CTRL-Y CTRL-Y 插入游標上方字元
i_CTRL-A CTRL-A 插入先前插入的文字 i_CTRL-@ CTRL-@ 插入先前插入的文字並停止插入模式 i_CTRL-R CTRL-R {暫存器} 插入暫存器的內容
i_CTRL-N CTRL-N 插入游標之前識別符號的下一個匹配項 i_CTRL-P CTRL-P 插入游標之前識別符號的上一個匹配項 i_CTRL-X CTRL-X ... 以各種方式完成游標之前的單字
i_<BS> <BS>CTRL-H 刪除游標之前的字元 i_<Del> <Del> 刪除游標下的字元 i_CTRL-W CTRL-W 刪除游標之前的單字 i_CTRL-U CTRL-U 刪除目前行中輸入的所有字元 i_CTRL-T CTRL-T 在目前行前面插入一個 shiftwidth 的縮排 i_CTRL-D CTRL-D 刪除目前行前面的一個 shiftwidth 的縮排 i_0_CTRL-D 0 CTRL-D 刪除目前行中的所有縮排 i_^_CTRL-D ^ CTRL-D 刪除目前行中的所有縮排,並在下一行中恢復縮排

Q_di 雙字母組合

:dig :dig[raphs] 顯示目前的雙字母組合列表 :dig :dig[raphs] {字元1}{字元2} {數字} ... 將雙字母組合加入列表
在插入或命令列模式中: i_CTRL-K CTRL-K {字元1} {字元2} 輸入雙字母組合 i_digraph {字元1} <BS> {字元2} 如果 'digraph' 選項已設定,則輸入雙字母組合

Q_si 特殊插入

:r :r [檔案] 在游標下方插入 [檔案] 的內容 :r! :r! {指令} 在游標下方插入 {指令} 的標準輸出

Q_de 刪除文字

x N x 刪除游標下和之後的 N 個字元 <Del> N <Del> 刪除游標下和之後的 N 個字元 X N X 刪除游標之前的 N 個字元 d N d{移動} 刪除透過 {移動} 移動的文字 v_d {視覺}d 刪除醒目標示的文字 dd N dd 刪除 N 行 D N D 刪除到行尾 (以及額外的 N-1 行) J N J 合併 N-1 行 (刪除 <EOL>) v_J {視覺}J 合併醒目標示的行 gJ N gJ 類似於 "J",但不插入空格 v_gJ {視覺}gJ 類似於 "{visual}J",但不插入空格 :d :[範圍]d [x] 刪除 [範圍] 行 [到暫存器 x]

Q_cm 複製和移動文字

quote "{字元} 使用暫存器 {字元} 進行下一次刪除、複製或貼上 :reg :reg 顯示所有暫存器的內容 :reg :reg {參數} 顯示 {參數} 中提及的暫存器的內容 y N y{移動} 將透過 {移動} 移動的文字複製到暫存器 v_y {視覺}y 將醒目標示的文字複製到暫存器 yy N yy 將 N 行複製到暫存器 Y N Y 將 N 行複製到暫存器 注意: 預設對應到 "y$"。 default-mappings p N p 將暫存器貼到游標位置之後 (N 次) P N P 將暫存器貼到游標位置之前 (N 次) ]p N ]p 類似於 p,但調整縮排以符合目前行 [p N [p 類似於 P,但調整縮排以符合目前行 gp N gp 類似於 p,但將游標留在新文字之後 gP N gP 類似於 P,但將游標留在新文字之後

Q_ch 變更文字

r N r{字元} 以 {字元} 取代 N 個字元 gr N gr{字元} 取代 N 個字元,但不影響版面配置 R N R 進入取代模式 (重複輸入的文字 N 次) gR N gR 進入虛擬取代模式:類似於取代模式,但不影響版面配置 v_b_r {視覺}r{字元} 在視覺區塊模式中:以 {字元} 取代選定文字的每個字元
(變更 = 刪除文字並進入插入模式) c N c{移動} 變更透過 {移動} 移動的文字 v_c {視覺}c 變更醒目標示的文字 cc N cc 變更 N 行 S N S 變更 N 行 C N C 變更到行尾 (以及額外的 N-1 行) s N s 變更 N 個字元 v_b_c {視覺}c 在視覺區塊模式中:以輸入的文字變更每個選定的行 v_b_C {視覺}C 在視覺區塊模式中:以輸入的文字變更每個選定的行直到行尾
~ N ~ 切換 N 個字元的案例並前進游標 v_~ {visual}~ 切換選取文字的案例 v_u {visual}u 將選取文字轉為小寫 v_U {visual}U 將選取文字轉為大寫 g~ g~{motion} 切換以 {motion} 移動到的文字案例 gu gu{motion} 將以 {motion} 移動到的文字轉為小寫 gU gU{motion} 將以 {motion} 移動到的文字轉為大寫 v_g? {visual}g? 對選取文字執行 rot13 編碼 g? g?{motion} 對以 {motion} 移動到的文字執行 rot13 編碼
CTRL-A N CTRL-A 將 N 加到游標所在或之後的數字 CTRL-X N CTRL-X 從游標所在或之後的數字減去 N
< N <{motion} 將以 {motion} 移動到的行向左移動一個 shiftwidth << N << 將 N 行向左移動一個 shiftwidth > N >{motion} 將以 {motion} 移動到的行向右移動一個 shiftwidth >> N >> 將 N 行向右移動一個 shiftwidth gq N gq{motion} 將以 {motion} 移動到的行格式化為 'textwidth' 長度 :ce :[範圍]ce[nter] [寬度] 將 [範圍] 內的行置中 :le :[範圍]le[ft] [縮排] 將 [範圍] 內的行靠左對齊 (使用 [縮排]) :ri :[範圍]ri[ght] [寬度] 將 [範圍] 內的行靠右對齊

Q_co 複雜變更

! N !{motion}{command}<CR> 將移動到的行通過 {command} 過濾 !! N !!{command}<CR> 將 N 行通過 {command} 過濾 v_! {visual}!{command}<CR> 將選取的行通過 {command} 過濾 :range! :[範圍]! {command}<CR> 將 [範圍] 內的行通過 {command} 過濾 = N ={motion} 將以 {motion} 移動到的行通過 'equalprg' 過濾 == N == 將 N 行通過 'equalprg' 過濾 v_= {visual}= 將選取的行通過 'equalprg' 過濾 :s :[範圍]s[ubstitute]/{pattern}/{string}/[g][c] 將 [範圍] 內的行中 {pattern} 替換為 {string};使用 [g] 替換所有 {pattern} 的出現;使用 [c] 確認每個替換 :s :[範圍]s[ubstitute] [g][c] 使用新的範圍和選項重複先前的 ":s" & & 在目前行上重複先前的 ":s",不帶選項 :ret :[範圍]ret[ab][!] [tabstop] 將 'tabstop' 設定為新值並相應地調整空白

Q_vi 可視模式

visual-index 可視模式命令列表。
v v 開始選取字元 } 移動游標並使用 V V 開始選取行 } 運算子來影響 CTRL-V CTRL-V 開始選取區塊 } 選取的文字 v_o o 將游標位置與選取開始處交換 gv gv 在先前可視區域上開始選取 v_v v 選取字元或停止選取 v_V V 選取行或停止選取 v_CTRL-V CTRL-V 選取區塊或停止選取

Q_to 文字物件 (僅在可視模式或運算子之後)

v_aw N aw 選取「一個單字」 v_iw N iw 選取「內部單字」 v_aW N aW 選取「一個 WORDv_iW N iW 選取「內部 WORDv_as N as 選取「一個句子」 v_is N is 選取「內部句子」 v_ap N ap 選取「一個段落」 v_ip N ip 選取「內部段落」 v_ab N ab 選取「一個區塊」(從 "[(" 到 "])") v_ib N ib 選取「內部區塊」(從 "[(" 到 "])") v_aB N aB 選取「一個區塊」(從 [{]}) v_iB N iB 選取「內部區塊」(從 [{]}) v_a> N a> 選取「一個 <> 區塊」 v_i> N i> 選取「內部 <> 區塊」 v_at N at 選取「一個標籤區塊」(從 <aaa> 到 </aaa>) v_it N it 選取「內部標籤區塊」(從 <aaa> 到 </aaa>) v_a' N a' 選取「一個單引號字串」 v_i' N i' 選取「內部單引號字串」 v_aquote N a" 選取「一個雙引號字串」 v_iquote N i" 選取「內部雙引號字串」 v_a` N a` 選取「一個反引號字串」 v_i` N i` 選取「內部反引號字串」

Q_re 重複命令

. N . 重複上次變更 (計數取代為 N) q q{a-z} 將輸入的字元記錄到暫存器 {a-z} q q{A-Z} 將輸入的字元記錄到暫存器 {a-z},並附加到其後 q q 停止記錄 Q Q 重新播放上次記錄的巨集 @ N @{a-z} 執行暫存器 {a-z} 的內容 (N 次) @@ N @@ 重複先前的 @{a-z} (N 次) :@ :@{a-z} 將暫存器 {a-z} 的內容作為 Ex 命令執行 :@@ :@@ 重複先前的 :@{a-z} :g :[範圍]g[lobal]/{pattern}/[cmd] 在 [範圍] 內與 {pattern} 匹配的行上執行 Ex 命令 [cmd] (預設值: ":p") :g :[範圍]g[lobal]!/{pattern}/[cmd] 在 [範圍] 內與 {pattern} 不匹配的行上執行 Ex 命令 [cmd] (預設值: ":p") :so :so[urce] {file}{file} 讀取 Ex 命令 :so :so[urce]! {file}{file} 讀取 Vim 命令 :sl :sl[eep] [秒] 在 [秒] 內不執行任何操作 gs N gs 進入睡眠狀態 N 秒

Q_km 按鍵映射

:map :ma[p] {lhs} {rhs} 在一般和可視模式下將 {lhs} 映射到 {rhs} :map! :ma[p]! {lhs} {rhs} 在插入和命令列模式下將 {lhs} 映射到 {rhs} :noremap :no[remap][!] {lhs} {rhs} 與 ":map" 相同,此 {rhs} 不會重新映射 :unmap :unm[ap] {lhs} 移除一般和可視模式下 {lhs} 的映射 :unmap! :unm[ap]! {lhs} 移除插入和命令列模式下 {lhs} 的映射 :map_l :ma[p] [lhs] 列出一般和可視模式的映射 (以 [lhs] 開頭) :map_l! :ma[p]! [lhs] 列出插入和命令列模式的映射 (以 [lhs] 開頭) :cmap :cmap/:cunmap/:cnoremap 類似於 ":map!"/":unmap!"/":noremap!",但僅適用於命令列模式 :imap :imap/:iunmap/:inoremap 類似於 ":map!"/":unmap!"/":noremap!",但僅適用於插入模式 :nmap :nmap/:nunmap/:nnoremap 類似於 ":map"/":unmap"/":noremap",但僅適用於一般模式 :vmap :vmap/:vunmap/:vnoremap 類似於 ":map"/":unmap"/":noremap",但僅適用於可視模式 :omap :omap/:ounmap/:onoremap 類似於 ":map"/":unmap"/":noremap",但僅適用於運算子等待時 :mapc :mapc[lear] 移除一般和可視模式的映射 :mapc :mapc[lear]! 移除插入和命令列模式的映射 :imapc :imapc[lear] 移除插入模式的映射 :vmapc :vmapc[lear] 移除可視模式的映射 :omapc :omapc[lear] 移除運算子等待模式的映射 :nmapc :nmapc[lear] 移除一般模式的映射 :cmapc :cmapc[lear] 移除命令列模式的映射 :mkexrc :mk[exrc][!] [檔案] 將目前的映射、縮寫和設定寫入 [檔案] (預設值: ".exrc"; 使用 ! 覆蓋) :mkvimrc :mkv[imrc][!] [檔案] 與 :mkexrc 相同,但預設使用 ".nvimrc" :mksession :mks[ession][!] [檔案] 類似於 ":mkvimrc",但也會儲存目前檔案、視窗等,以便稍後繼續此工作階段

Q_ab 縮寫

:abbreviate :ab[breviate] {lhs} {rhs}{lhs} 新增到 {rhs} 的縮寫 :abbreviate :ab[breviate] {lhs} 顯示以 {lhs} 開頭的縮寫 :abbreviate :ab[breviate] 顯示所有縮寫 :unabbreviate :una[bbreviate] {lhs} 移除 {lhs} 的縮寫 :noreabbrev :norea[bbrev] [lhs] [rhs] 類似於 ":ab",但不會重新映射 [rhs] :iabbrev :iab/:iunab/:inoreab 類似於 ":ab",但僅適用於插入模式 :cabbrev :cab/:cunab/:cnoreab 類似於 ":ab",但僅適用於命令列模式 :abclear :abc[lear] 移除所有縮寫 :cabclear :cabc[lear] 移除命令列模式的所有縮寫 :iabclear :iabc[lear] 移除插入模式的所有縮寫

Q_op 選項

:set :se[t] 顯示所有已修改的選項 :set :se[t] all 顯示所有選項 :set :se[t] {option} 設定布林選項 (開啟)、顯示字串或數字選項 :set :se[t] no{option} 重設布林選項 (關閉) :set :se[t] inv{option} 反轉布林選項 :set :se[t] {option}={value} 將字串/數字選項設定為 {value} :set :se[t] {option}+={value} 將 {value} 附加到字串選項、將 {value} 加到數字選項 :set :se[t] {option}-={value} 從字串選項移除 {value}、從數字選項減去 {value} :set :se[t] {option} 顯示 {option} 的值 :set :se[t] {option}& 將 {option} 重設為其預設值
:setlocal :setl[ocal] 類似於 ":set",但設定具有區域值的選項的區域值 :setglobal :setg[lobal] 類似於 ":set",但設定區域選項的全域值
:options :opt[ions] 開啟一個新視窗以檢視和設定選項,按功能分組,並提供一行說明和指向說明文件的連結
每個選項的簡短說明: option-list
'allowrevins' 'ari' allow CTRL-_ in Insert mode 'ambiwidth' 'ambw' what to do with Unicode chars of ambiguous width 'arabic' 'arab' for Arabic as a default second language 'arabicshape' 'arshape' do shaping for Arabic characters 'autochdir' 'acd' change directory to the file in the current window 'autoindent' 'ai' take indent for new line from previous line 'autoread' 'ar' autom. read file when changed outside of Vim 'autowrite' 'aw' automatically write file if changed 'autowriteall' 'awa' as 'autowrite', but works with more commands 'background' 'bg' "dark" or "light", used for highlight colors 'backspace' 'bs' how backspace works at start of line 'backup' 'bk' keep backup file after overwriting a file 'backupcopy' 'bkc' make backup as a copy, don't rename the file 'backupdir' 'bdir' list of directories for the backup file 'backupext' 'bex' extension used for the backup file 'backupskip' 'bsk' no backup for files that match these patterns 'belloff' 'bo' do not ring the bell for these reasons 'binary' 'bin' read/write/edit file in binary mode 'bomb' prepend a Byte Order Mark to the file 'breakat' 'brk' characters that may cause a line break 'breakindent' 'bri' wrapped line repeats indent 'breakindentopt' 'briopt' settings for 'breakindent' 'browsedir' 'bsdir' which directory to start browsing in 'bufhidden' 'bh' what to do when buffer is no longer in window 'buflisted' 'bl' whether the buffer shows up in the buffer list 'buftype' 'bt' special type of buffer 'casemap' 'cmp' specifies how case of letters is changed 'cdhome' 'cdh' change directory to the home directory by ":cd" 'cdpath' 'cd' list of directories searched with ":cd" 'cedit' key used to open the command-line window 'charconvert' 'ccv' expression for character encoding conversion 'cindent' 'cin' do C program indenting 'cinkeys' 'cink' keys that trigger indent when 'cindent' is set 'cinoptions' 'cino' how to do indenting when 'cindent' is set 'cinscopedecls' 'cinsd' words that are recognized by 'cino-g' 'cinwords' 'cinw' words where 'si' and 'cin' add an indent 'clipboard' 'cb' use the clipboard as the unnamed register 'cmdheight' 'ch' number of lines to use for the command-line 'cmdwinheight' 'cwh' height of the command-line window 'colorcolumn' 'cc' columns to highlight 'columns' 'co' number of columns in the display 'comments' 'com' patterns that can start a comment line 'commentstring' 'cms' template for comments; used for fold marker 'complete' 'cpt' specify how Insert mode completion works 'completefunc' 'cfu' function to be used for Insert mode completion 'completeopt' 'cot' options for Insert mode completion 'completeslash' 'csl' like 'shellslash' for completion 'concealcursor' 'cocu' whether concealable text is hidden in cursor line 'conceallevel' 'cole' whether concealable text is shown or hidden 'confirm' 'cf' ask what to do about unsaved/read-only files 'copyindent' 'ci' make 'autoindent' use existing indent structure 'cpoptions' 'cpo' flags for Vi-compatible behavior 'cursorbind' 'crb' move cursor in window as it moves in other windows 'cursorcolumn' 'cuc' highlight the screen column of the cursor 'cursorline' 'cul' highlight the screen line of the cursor 'cursorlineopt' 'culopt' settings for 'cursorline' 'debug' set to "msg" to see all error messages 'define' 'def' pattern to be used to find a macro definition 'delcombine' 'deco' delete combining characters on their own 'dictionary' 'dict' list of file names used for keyword completion 'diff' use diff mode for the current window 'diffexpr' 'dex' expression used to obtain a diff file 'diffopt' 'dip' options for using diff mode 'digraph' 'dg' enable the entering of digraphs in Insert mode 'directory' 'dir' list of directory names for the swap file 'display' 'dy' list of flags for how to display text 'eadirection' 'ead' in which direction 'equalalways' works 'encoding' 'enc' encoding used internally 'endoffile' 'eof' write CTRL-Z at end of the file 'endofline' 'eol' write <EOL> for last line in file 'equalalways' 'ea' windows are automatically made the same size 'equalprg' 'ep' external program to use for "=" command 'errorbells' 'eb' ring the bell for error messages 'errorfile' 'ef' name of the errorfile for the QuickFix mode 'errorformat' 'efm' description of the lines in the error file 'eventignore' 'ei' autocommand events that are ignored 'expandtab' 'et' use spaces when <Tab> is inserted 'exrc' 'ex' read init files in the current directory 'fileencoding' 'fenc' file encoding for multibyte text 'fileencodings' 'fencs' automatically detected character encodings 'fileformat' 'ff' file format used for file I/O 'fileformats' 'ffs' automatically detected values for 'fileformat' 'fileignorecase' 'fic' ignore case when using file names 'filetype' 'ft' type of file, used for autocommands 'fillchars' 'fcs' characters to use for displaying special items 'findfunc' 'ffu' function to be called for the :find command 'fixendofline' 'fixeol' make sure last line in file has <EOL> 'foldclose' 'fcl' close a fold when the cursor leaves it 'foldcolumn' 'fdc' width of the column used to indicate folds 'foldenable' 'fen' set to display all folds open 'foldexpr' 'fde' expression used when 'foldmethod' is "expr" 'foldignore' 'fdi' ignore lines when 'foldmethod' is "indent" 'foldlevel' 'fdl' close folds with a level higher than this 'foldlevelstart' 'fdls' 'foldlevel' when starting to edit a file 'foldmarker' 'fmr' markers used when 'foldmethod' is "marker" 'foldmethod' 'fdm' folding type 'foldminlines' 'fml' minimum number of lines for a fold to be closed 'foldnestmax' 'fdn' maximum fold depth 'foldopen' 'fdo' for which commands a fold will be opened 'foldtext' 'fdt' expression used to display for a closed fold 'formatexpr' 'fex' expression used with "gq" command 'formatlistpat' 'flp' pattern used to recognize a list header 'formatoptions' 'fo' how automatic formatting is to be done 'formatprg' 'fp' name of external program used with "gq" command 'fsync' 'fs' whether to invoke fsync() after file write 'gdefault' 'gd' the ":substitute" flag 'g' is default on 'grepformat' 'gfm' format of 'grepprg' output 'grepprg' 'gp' program to use for ":grep" 'guicursor' 'gcr' GUI: settings for cursor shape and blinking 'guifont' 'gfn' GUI: Name(s) of font(s) to be used 'guifontwide' 'gfw' list of font names for double-wide characters 'guioptions' 'go' GUI: Which components and options are used 'guitablabel' 'gtl' GUI: custom label for a tab page 'guitabtooltip' 'gtt' GUI: custom tooltip for a tab page 'helpfile' 'hf' full path name of the main help file 'helpheight' 'hh' minimum height of a new help window 'helplang' 'hlg' preferred help languages 'hidden' 'hid' don't unload buffer when it is abandoned 'history' 'hi' number of command-lines that are remembered 'hlsearch' 'hls' highlight matches with last search pattern 'icon' let Vim set the text of the window icon 'iconstring' string to use for the Vim icon text 'ignorecase' 'ic' ignore case in search patterns 'imcmdline' 'imc' use IM when starting to edit a command line 'imdisable' 'imd' do not use the IM in any mode 'iminsert' 'imi' use :lmap or IM in Insert mode 'imsearch' 'ims' use :lmap or IM when typing a search pattern 'include' 'inc' pattern to be used to find an include file 'includeexpr' 'inex' expression used to process an include line 'incsearch' 'is' highlight match while typing search pattern 'indentexpr' 'inde' expression used to obtain the indent of a line 'indentkeys' 'indk' keys that trigger indenting with 'indentexpr' 'infercase' 'inf' adjust case of match for keyword completion 'isfname' 'isf' characters included in file names and pathnames 'isident' 'isi' characters included in identifiers 'iskeyword' 'isk' characters included in keywords 'isprint' 'isp' printable characters 'joinspaces' 'js' two spaces after a period with a join command 'jumpoptions' 'jop' specifies how jumping is done 'keymap' 'kmp' name of a keyboard mapping 'keymodel' 'km' enable starting/stopping selection with keys 'keywordprg' 'kp' program to use for the "K" command 'langmap' 'lmap' alphabetic characters for other language mode 'langmenu' 'lm' language to be used for the menus 'langremap' 'lrm' do apply 'langmap' to mapped characters 'laststatus' 'ls' tells when last window has status lines 'lazyredraw' 'lz' don't redraw while executing macros 'linebreak' 'lbr' wrap long lines at a blank 'lines' number of lines in the display 'linespace' 'lsp' number of pixel lines to use between characters 'lisp' automatic indenting for Lisp 'lispoptions' 'lop' changes how Lisp indenting is done 'lispwords' 'lw' words that change how lisp indenting works 'list' show <Tab> and <EOL> 'listchars' 'lcs' characters for displaying in list mode 'loadplugins' 'lpl' load plugin scripts when starting up 'magic' changes special characters in search patterns 'makeef' 'mef' name of the errorfile for ":make" 'makeencoding' 'menc' encoding of external make/grep commands 'makeprg' 'mp' program to use for the ":make" command 'matchpairs' 'mps' pairs of characters that "%" can match 'matchtime' 'mat' tenths of a second to show matching paren 'maxcombine' 'mco' maximum nr of combining characters displayed 'maxfuncdepth' 'mfd' maximum recursive depth for user functions 'maxmapdepth' 'mmd' maximum recursive depth for mapping 'maxmempattern' 'mmp' maximum memory (in Kbyte) used for pattern search 'menuitems' 'mis' maximum number of items in a menu 'mkspellmem' 'msm' memory used before :mkspell compresses the tree 'modeline' 'ml' recognize modelines at start or end of file 'modelineexpr' 'mle' allow setting expression options from a modeline 'modelines' 'mls' number of lines checked for modelines 'modifiable' 'ma' changes to the text are not possible 'modified' 'mod' buffer has been modified 'more' pause listings when the whole screen is filled 'mouse' enable the use of mouse clicks 'mousefocus' 'mousef' keyboard focus follows the mouse 'mousehide' 'mh' hide mouse pointer while typing 'mousemodel' 'mousem' changes meaning of mouse buttons 'mousemoveevent' 'mousemev' report mouse moves with <MouseMove> 'mousescroll' amount to scroll by when scrolling with a mouse 'mouseshape' 'mouses' shape of the mouse pointer in different modes 'mousetime' 'mouset' max time between mouse double-click 'nrformats' 'nf' number formats recognized for CTRL-A command 'number' 'nu' print the line number in front of each line 'numberwidth' 'nuw' number of columns used for the line number 'omnifunc' 'ofu' function for filetype-specific completion 'opendevice' 'odev' allow reading/writing devices on MS-Windows 'operatorfunc' 'opfunc' function to be called for g@ operator 'packpath' 'pp' list of directories used for packages 'paragraphs' 'para' nroff macros that separate paragraphs 'patchexpr' 'pex' expression used to patch a file 'patchmode' 'pm' keep the oldest version of a file 'path' 'pa' list of directories searched with "gf" et.al. 'preserveindent' 'pi' preserve the indent structure when reindenting 'previewheight' 'pvh' height of the preview window 'previewwindow' 'pvw' identifies the preview window 'pumheight' 'ph' maximum number of items to show in the popup menu 'pumwidth' 'pw' minimum width of the popup menu 'pyxversion' 'pyx' Python version used for pyx* commands 'quoteescape' 'qe' escape characters used in a string 'readonly' 'ro' disallow writing the buffer 'redrawtime' 'rdt' timeout for 'hlsearch' and :match highlighting 'regexpengine' 're' default regexp engine to use 'relativenumber' 'rnu' show relative line number in front of each line 'report' threshold for reporting nr. of lines changed 'revins' 'ri' inserting characters will work backwards 'rightleft' 'rl' window is right-to-left oriented 'rightleftcmd' 'rlc' commands for which editing works right-to-left 'ruler' 'ru' show cursor line and column in the status line 'rulerformat' 'ruf' custom format for the ruler 'runtimepath' 'rtp' list of directories used for runtime files 'scroll' 'scr' lines to scroll with CTRL-U and CTRL-D 'scrollbind' 'scb' scroll in window as other windows scroll 'scrolljump' 'sj' minimum number of lines to scroll 'scrolloff' 'so' minimum nr. of lines above and below cursor 'scrollopt' 'sbo' how 'scrollbind' should behave 'sections' 'sect' nroff macros that separate sections 'secure' secure mode for reading .vimrc in current dir 'selection' 'sel' what type of selection to use 'selectmode' 'slm' when to use Select mode instead of Visual mode 'sessionoptions' 'ssop' options for :mksession 'shada' 'sd' use .shada file upon startup and exiting 'shell' 'sh' name of shell to use for external commands 'shellcmdflag' 'shcf' flag to shell to execute one command 'shellpipe' 'sp' string to put output of ":make" in error file 'shellquote' 'shq' quote character(s) for around shell command 'shellredir' 'srr' string to put output of filter in a temp file 'shellslash' 'ssl' use forward slash for shell file names 'shelltemp' 'stmp' whether to use a temp file for shell commands 'shellxescape' 'sxe' characters to escape when 'shellxquote' is ( 'shellxquote' 'sxq' like 'shellquote', but include redirection 'shiftround' 'sr' round indent to multiple of shiftwidth 'shiftwidth' 'sw' number of spaces to use for (auto)indent step 'shortmess' 'shm' list of flags, reduce length of messages 'showbreak' 'sbr' string to use at the start of wrapped lines 'showcmd' 'sc' show (partial) command somewhere 'showcmdloc' 'sloc' where to show (partial) command 'showfulltag' 'sft' show full tag pattern when completing tag 'showmatch' 'sm' briefly jump to matching bracket if insert one 'showmode' 'smd' message on status line to show current mode 'showtabline' 'stal' tells when the tab pages line is displayed 'sidescroll' 'ss' minimum number of columns to scroll horizontal 'sidescrolloff' 'siso' min. nr. of columns to left and right of cursor 'signcolumn' 'scl' when and how to display the sign column 'smartcase' 'scs' no ignore case when pattern has uppercase 'smartindent' 'si' smart autoindenting for C programs 'smarttab' 'sta' use 'shiftwidth' when inserting <Tab> 'smoothscroll' 'sms' scroll by screen lines when 'wrap' is set 'softtabstop' 'sts' number of spaces that <Tab> uses while editing 'spell' enable spell checking 'spellcapcheck' 'spc' pattern to locate end of a sentence 'spellfile' 'spf' files where zg and zw store words 'spelllang' 'spl' language(s) to do spell checking for 'spelloptions' 'spo' options for spell checking 'spellsuggest' 'sps' method(s) used to suggest spelling corrections 'splitbelow' 'sb' new window from split is below the current one 'splitkeep' 'spk' determines scroll behavior for split windows 'splitright' 'spr' new window is put right of the current one 'startofline' 'sol' commands move cursor to first non-blank in line 'statuscolumn' 'stc' custom format for the status column 'statusline' 'stl' custom format for the status line 'suffixes' 'su' suffixes that are ignored with multiple match 'suffixesadd' 'sua' suffixes added when searching for a file 'swapfile' 'swf' whether to use a swapfile for a buffer 'switchbuf' 'swb' sets behavior when switching to another buffer 'synmaxcol' 'smc' maximum column to find syntax items 'syntax' 'syn' syntax to be loaded for current buffer 'tabclose' 'tcl' which tab page to focus when closing a tab 'tabline' 'tal' custom format for the console tab pages line 'tabpagemax' 'tpm' maximum number of tab pages for -p and "tab all" 'tabstop' 'ts' number of spaces that <Tab> in file uses 'tagbsearch' 'tbs' use binary searching in tags files 'tagcase' 'tc' how to handle case when searching in tags files 'tagfunc' 'tfu' function to get list of tag matches 'taglength' 'tl' number of significant characters for a tag 'tagrelative' 'tr' file names in tag file are relative 'tags' 'tag' list of file names used by the tag command 'tagstack' 'tgst' push tags onto the tag stack 'term' name of the terminal 'termbidi' 'tbidi' terminal takes care of bi-directionality 'termguicolors' 'tgc' enable 24-bit RGB color in the TUI 'textwidth' 'tw' maximum width of text that is being inserted 'thesaurus' 'tsr' list of thesaurus files for keyword completion 'thesaurusfunc' 'tsrfu' function to be used for thesaurus completion 'tildeop' 'top' tilde command "~" behaves like an operator 'timeout' 'to' time out on mappings and key codes 'timeoutlen' 'tm' time out time in milliseconds 'title' let Vim set the title of the window 'titlelen' percentage of 'columns' used for window title 'titleold' old title, restored when exiting 'titlestring' string to use for the Vim window title 'ttimeout' time out on mappings 'ttimeoutlen' 'ttm' time out time for key codes in milliseconds 'ttytype' 'tty' alias for 'term' 'undodir' 'udir' where to store undo files 'undofile' 'udf' save undo information in a file 'undolevels' 'ul' maximum number of changes that can be undone 'undoreload' 'ur' max nr of lines to save for undo on a buffer reload 'updatecount' 'uc' after this many characters flush swap file 'updatetime' 'ut' after this many milliseconds flush swap file 'varsofttabstop' 'vsts' a list of number of spaces when typing <Tab> 'vartabstop' 'vts' a list of number of spaces for <Tab>s 'verbose' 'vbs' give informative messages 'verbosefile' 'vfile' file to write messages in 'viewdir' 'vdir' directory where to store files with :mkview 'viewoptions' 'vop' specifies what to save for :mkview 'virtualedit' 've' when to use virtual editing 'visualbell' 'vb' use visual bell instead of beeping 'warn' warn for shell command when buffer was changed 'whichwrap' 'ww' allow specified keys to cross line boundaries 'wildchar' 'wc' command-line character for wildcard expansion 'wildcharm' 'wcm' like 'wildchar' but also works when mapped 'wildignore' 'wig' files matching these patterns are not completed 'wildignorecase' 'wic' ignore case when completing file names 'wildmenu' 'wmnu' use menu for command line completion 'wildmode' 'wim' mode for 'wildchar' command-line expansion 'wildoptions' 'wop' specifies how command line completion is done 'winaltkeys' 'wak' when the windows system handles ALT keys 'window' 'wi' nr of lines to scroll for CTRL-F and CTRL-B 'winfixbuf' 'wfb' keep window focused on a single buffer 'winfixheight' 'wfh' keep window height when opening/closing windows 'winfixwidth' 'wfw' keep window width when opening/closing windows 'winheight' 'wh' minimum number of lines for the current window 'winhighlight' 'winhl' window-local highlighting 'winminheight' 'wmh' minimum number of lines for any window 'winminwidth' 'wmw' minimal number of columns for any window 'winwidth' 'wiw' minimal number of columns for current window 'wrap' long lines wrap and continue on the next line 'wrapmargin' 'wm' chars from the right where wrapping starts 'wrapscan' 'ws' searches wrap around the end of the file 'write' writing to a file is allowed 'writeany' 'wa' write to file with no need for "!" override 'writebackup' 'wb' make a backup before overwriting a file 'writedelay' 'wd' delay this many msec for each char (for debug)

Q_ur 復原/重做命令

u N u 復原最後 N 次變更 CTRL-R N CTRL-R 重做最後 N 次復原的變更 U U 還原最後變更的行

Q_et 外部命令

:! :!{command} 使用 shell 執行 {command} K K 使用 'keywordprg' 程式 (預設值: "man") 查詢游標下的關鍵字

Q_qf 快速修正命令

:cc :cc [nr] 顯示錯誤 [nr] (預設為再次顯示相同的錯誤) :cnext :cn 顯示下一個錯誤 :cprevious :cp 顯示上一個錯誤 :clist :cl 列出所有錯誤 :cfile :cf 從檔案讀取錯誤 'errorfile' :cgetbuffer :cgetb 類似 :cbuffer 但不會跳到第一個錯誤 :cgetfile :cg 類似 :cfile 但不會跳到第一個錯誤 :cgetexpr :cgete 類似 :cexpr 但不會跳到第一個錯誤 :caddfile :caddf 從錯誤檔案將錯誤添加到目前的快速修復列表 :caddexpr :cad 從表達式將錯誤添加到目前的快速修復列表 :cbuffer :cb 從緩衝區中的文字讀取錯誤 :cexpr :cex 從表達式讀取錯誤 :cquit :cq 不寫入並退出,並傳回錯誤碼 (給編譯器) :make :make [args] 啟動 make,讀取錯誤並跳到第一個錯誤 :grep :gr[ep] [args] 執行 'grepprg' 以尋找匹配並跳到第一個匹配項

Q_vc 各種指令

CTRL-L CTRL-L 清除並重繪畫面 CTRL-G CTRL-G 顯示目前檔案名稱 (包含路徑) 和游標位置 ga ga 顯示游標下字元的 ascii 值,以十進位、十六進位和八進位表示 g8 g8 用於 utf-8 編碼:顯示游標下字元的位元組序列,以十六進位表示 g_CTRL-G g CTRL-G 顯示游標欄、行和字元位置 CTRL-C CTRL-C 在搜尋期間:中斷搜尋 <Del> <Del> 在輸入計數時:刪除最後一個字元 :version :ve[rsion] 顯示版本資訊 :normal :norm[al][!] {commands} 執行一般模式指令 gQ gQ 切換到 "Ex" 模式
:redir :redir >{file} 將訊息重新導向到 {file} :silent :silent[!] {command} 靜默執行 {command} :confirm :confirm {command} 退出、寫入等,詢問未儲存的變更或唯讀檔案 :browse :browse {command} 使用檔案選擇對話框開啟/讀取/寫入檔案

Q_ce 命令列編輯

c_<Esc> <Esc> 放棄命令列 (如果 'wildchar'<Esc>,請輸入兩次)
c_CTRL-V CTRL-V {char} 逐字插入 {char} c_CTRL-V CTRL-V {number} 輸入字元的十進位值 (最多三位數) c_CTRL-K CTRL-K {char1} {char2} 輸入二合字母 (請參閱 Q_di) c_CTRL-R CTRL-R {register} 插入暫存器的內容
c_<Left> <Left>/<Right> 游標左/右移動 c_<S-Left> <S-Left>/<S-Right> 游標左/右移動一個字 c_CTRL-B CTRL-B/CTRL-E 游標移動到命令列的開頭/結尾
c_<BS> <BS> 刪除游標前面的字元 c_<Del> <Del> 刪除游標下的字元 c_CTRL-W CTRL-W 刪除游標前面的單字 c_CTRL-U CTRL-U 移除所有字元
c_<Up> <Up>/<Down> 重新呼叫以目前命令開頭的較舊/較新的命令列 c_<S-Up> <S-Up>/<S-Down> 從歷史記錄中重新呼叫較舊/較新的命令列 c_CTRL-G CTRL-G'incsearch' 啟用時,顯示下一個匹配項 c_CTRL-T CTRL-T'incsearch' 啟用時,顯示上一個匹配項 :history :his[tory] 顯示較舊的命令列
命令列上的上下文相關完成
c_wildchar 'wildchar' (預設值:<Tab>) 對游標前面的模式進行完成;如果有多个匹配项,则会发出提示音并显示第一个;进一步使用 'wildchar' 将显示下一个匹配项 c_CTRL-D CTRL-D 列出游標前面符合模式的所有名稱 c_CTRL-A CTRL-A 插入游標前面符合模式的所有名稱 c_CTRL-L CTRL-L 插入符合模式的名稱中最長且共有的部分 c_CTRL-N CTRL-N'wildchar' 具有多個匹配項後:移至下一個匹配項 c_CTRL-P CTRL-P'wildchar' 具有多個匹配項後:移至上一個匹配項

Q_ra Ex 範圍

:range , 分隔兩個行號 :range ; 相同,在解釋第二個行號之前,將游標設定為第一個行號
:range {number} 絕對行號 :range . 目前行 :range $ 檔案中的最後一行 :range % 等於 1,$ (整個檔案) :range * 等於 '<,'> (可視區域) :range 't 標記 t 的位置 :range /{pattern}[/] {pattern} 符合的下一行 :range ?{pattern}[?] {pattern} 符合的上一行
:range +[num] 將 [num] 加入先前的行號 (預設值:1) :range -[num] 從先前的行號減去 [num] (預設值:1)

Q_ex 特殊的 Ex 字元

:bar | 分隔兩個命令 (不適用於 ":global" 和 ":!") :quote " 開始註解
:_% % 目前檔案名稱 (僅在預期檔案名稱時) :_# #[num] 替代檔案名稱 [num] (僅在預期檔案名稱時) 注意:以下七個是逐字輸入;這些不是特殊按鍵! :<abuf> <abuf> 緩衝區編號,用於自動命令 (僅在預期檔案名稱時) :<afile> <afile> 檔案名稱,用於自動命令 (僅在預期檔案名稱時) :<amatch> <amatch> 與模式符合的內容,用於自動命令 (僅在預期檔案名稱時) :<cword> <cword> 游標下的單字 (僅在預期檔案名稱時) :<cWORD> <cWORD> 游標下的 WORD (僅在預期檔案名稱時) (請參閱 WORD) :<cfile> <cfile> 游標下的檔案名稱 (僅在預期檔案名稱時) :<sfile> <sfile> ":source" 檔案的檔案名稱,在該檔案內 (僅在預期檔案名稱時)
在 "%"、"#"、"<cfile>"、"<sfile>" 或 "<afile>" 之後 ::p :p 完整路徑 ::h :h head (已移除檔案名稱) ::t :t tail (僅檔案名稱) ::r :r root (已移除副檔名) ::e :e 副檔名 ::s :s/{pat}/{repl}/ 將 {pat} 替換為 {repl}

Q_st 啟動 Vim

-file vim [選項] {file} .. 開始編輯一個或多個檔案 -- vim [選項] - 從 stdin 讀取檔案 -tag vim [選項] -t {tag} 編輯與 {tag} 關聯的檔案 -qf vim [選項] -q [fname] 以 QuickFix 模式啟動編輯,顯示第一個錯誤
最常用的 Vim 引數 (完整列表請參閱 startup-options)
-+ +[num] 將游標放在 [num] 行 (預設值:最後一行) -+c +{command} 在載入檔案後執行 {command} -+/ +/{pat} {file} .. 將游標放在 {pat} 的第一個出現位置 -e -e Ex 模式,以 Ex 模式啟動 vim -R -R 唯讀模式,表示 -n -m -m 不允許修改 (重設 'write' 選項) -d -d diff 模式 -b -b 二進位模式 -l -l lisp 模式 -A -A 阿拉伯模式 (設定 'arabic') -H -H 希伯來模式 (設定希伯來鍵盤配置和 'rightleft') -V -V 详细模式,提供有用的信息 -r -r 列出交換檔案 -r -r {file} .. 復原已中止的編輯工作階段 -n -n 不建立交換檔案 -o -o [num] 開啟 [num] 個視窗 (預設值:每個檔案一個視窗) -s -s {scriptin} 首先從檔案 {scriptin} 讀取命令 -w -w {scriptout} 將輸入的字元寫入檔案 {scriptout} (附加) -W -W {scriptout} 將輸入的字元寫入檔案 {scriptout} (覆寫) -u -u {vimrc}{vimrc} 讀取初始化設定,而不是其他初始化設定 -i -i {shada}{shada} 讀取資訊,而不是其他檔案 --- -- 選項的結尾,其他引數為檔案名稱 --help --help 顯示引數清單並退出 --version --version 顯示版本資訊並退出 -- - 從 stdin 讀取檔案

Q_ed 編輯檔案

沒有 !: 如果目前的緩衝區已變更,則會失敗。 有 !: 捨棄目前緩衝區的任何變更。 :edit_f :e[dit][!] {file} 編輯 {file} :edit :e[dit][!] 重新載入目前的檔案 :enew :ene[w][!] 編輯新的、未命名的緩衝區 :find :fin[d][!] {file}'path' 中尋找 {file} 並編輯它
CTRL-^ N CTRL-^ 編輯替代檔案 N (相當於 ":e #N") gf gf 或 ]f 編輯游標下名稱的檔案 :pwd :pwd 列印目前的目錄名稱 :cd :cd [path] 將目前目錄變更為 [path] :cd- :cd - 返回先前的目前目錄 :file :f[ile] 列印目前的檔案名稱和游標位置 :file :f[ile] {name} 將目前的檔案名稱設定為 {name} :files :files 顯示替代檔案名稱

Q_fl 使用引數列表 argument-list

:args :ar[gs] 列印引數列表,目前檔案會用 "[]" 包起來 :all :all 或 :sall 為引數列表中的每個檔案開啟一個視窗 :wn :wn[ext][!] 寫入檔案並編輯下一個檔案 :wn :wn[ext][!] {file} 寫入至 {file} 並編輯下一個檔案,除非 {file} 已存在;加上 ! 會覆寫現有檔案 :wN :wN[ext][!] [file] 寫入檔案並編輯前一個檔案
在目前視窗 在新視窗
:argument :argu[ment] N :sar[gument] N 編輯檔案 N :next :n[ext] :sn[ext] 編輯下一個檔案 :next_f :n[ext] {arglist} :sn[ext] {arglist} 定義新的引數列表並編輯第一個檔案 :Next :N[ext] :sN[ext] 編輯前一個檔案 :first :fir[st] :sfir[st] 編輯第一個檔案 :last :la[st] :sla[st] 編輯最後一個檔案

Q_wq 寫入並退出

:w :[range]w[rite][!] 寫入至目前檔案 :w_f :[range]w[rite] {file} 寫入至 {file},除非該檔案已存在 :w_f :[range]w[rite]! {file} 寫入至 {file}。會覆寫現有檔案 :w_a :[range]w[rite][!] >> 附加到目前檔案 :w_a :[range]w[rite][!] >> {file} 附加到 {file} :w_c :[range]w[rite] !{cmd} 執行 {cmd} 並將 [range] 行作為標準輸入 :up :[range]up[date][!] 如果已修改,則寫入至目前檔案 :wall :wa[ll][!] 寫入所有已變更的緩衝區
:q :q[uit] 退出目前緩衝區,除非已進行變更;當沒有其他非說明緩衝區時,退出 Vim :q :q[uit]! 永遠退出目前緩衝區,捨棄所有變更。當沒有其他非說明緩衝區時,退出 Vim :qa :qa[ll] 退出 Vim,除非已進行變更 :qa :qa[ll]! 永遠退出 Vim,捨棄所有變更 :cq :cq 不寫入就退出,並回傳錯誤碼
:wq :wq[!] 寫入目前檔案並退出 :wq :wq[!] {file} 寫入至 {file} 並退出 :xit :x[it][!] [file] 類似 ":wq",但只在已進行變更時寫入 ZZ ZZ 與 ":x" 相同 ZQ ZQ 與 ":q!" 相同 :xall :xa[ll][!] 或 :wqall[!] 寫入所有已變更的緩衝區並退出
:stop :st[op][!] 暫停 Vim 或啟動新的 Shell;如果設定了 'aw' 選項且未指定 [!],則寫入緩衝區 CTRL-Z CTRL-Z 與 ":stop" 相同

Q_ac 自動指令

shada-file 在啟動時讀取暫存器、標記、歷史記錄,在退出時儲存。
:rshada :rsh[ada] [file] 從 ShaDa 檔案 [file] 讀取資訊 :rshada :rsh[ada]! [file] 同上,覆寫現有資訊 :wshada :wsh[ada] [file] 將資訊新增至 ShaDa 檔案 [file] :wshada :wsh[ada]! [file] 將資訊寫入至 ShaDa 檔案 [file]
modeline 在編輯檔案時自動設定選項
modeline vim:{set-arg}: .. 在檔案的第一行和最後一行 (請參閱 'ml' 選項),{set-arg} 會作為 ":set" 的引數給定
autocommand 在特定事件發生時自動執行指令。
:autocmd :au 列出所有自動指令 :autocmd :au {event} 列出 {event} 的所有自動指令 :autocmd :au {event} {pat} 列出 {event} 中符合 {pat} 的所有自動指令 :autocmd :au {event} {pat} {cmd} 輸入新的自動指令,用於 {event} 並符合 {pat} 的條件 :autocmd :au! 移除所有自動指令 :autocmd :au! {event} 移除 {event} 的所有自動指令 :autocmd :au! * {pat} 移除符合 {pat} 的所有自動指令 :autocmd :au! {event} {pat} 移除 {event} 中符合 {pat} 的所有自動指令 :autocmd :au! {event} {pat} {cmd} 移除 {event} 中符合 {pat} 的所有自動指令,並輸入新的自動指令

Q_wi 多視窗指令

CTRL-W_s CTRL-W s 或 :split 將視窗分割成兩個部分 :split_f :split {file} 分割視窗,並在其中一個視窗中編輯 {file} :vsplit :vsplit {file} 相同,但垂直分割 :vertical :vertical {cmd} 使 {cmd} 垂直分割
:sfind :sf[ind] {file} 分割視窗,在 'path' 中尋找 {file} 並編輯 :terminal :terminal {cmd} 開啟終端機視窗 CTRL-W_] CTRL-W ] 分割視窗並跳至游標下的標籤 CTRL-W_f CTRL-W f 分割視窗並編輯游標下的檔案名稱 CTRL-W_^ CTRL-W ^ 分割視窗並編輯替換檔案 CTRL-W_n CTRL-W n 或 :new 建立新的空白視窗 CTRL-W_q CTRL-W q 或 :q[uit] 退出編輯並關閉視窗 CTRL-W_c CTRL-W c 或 :clo[se] 將緩衝區隱藏並關閉視窗 CTRL-W_o CTRL-W o 或 :on[ly] 使目前視窗成為畫面上唯一的視窗
CTRL-W_j CTRL-W j 將游標移至下方視窗 CTRL-W_k CTRL-W k 將游標移至上方視窗 CTRL-W_CTRL-W CTRL-W CTRL-W 將游標移至下方視窗 (環繞) CTRL-W_W CTRL-W W 將游標移至上方視窗 (環繞) CTRL-W_t CTRL-W t 將游標移至頂端視窗 CTRL-W_b CTRL-W b 將游標移至底部視窗 CTRL-W_p CTRL-W p 將游標移至上一個活動視窗
CTRL-W_r CTRL-W r 向下旋轉視窗 CTRL-W_R CTRL-W R 向上旋轉視窗 CTRL-W_x CTRL-W x 將目前視窗與下一個視窗交換
CTRL-W_= CTRL-W = 使所有視窗的高度和寬度相等 CTRL-W_- CTRL-W - 減少目前視窗的高度 CTRL-W_+ CTRL-W + 增加目前視窗的高度 CTRL-W__ CTRL-W _ 設定目前視窗的高度 (預設值:非常高)
CTRL-W_< CTRL-W < 減少目前視窗的寬度 CTRL-W_> CTRL-W > 增加目前視窗的寬度 CTRL-W_bar CTRL-W | 設定目前視窗的寬度 (預設值:盡可能寬)

Q_bu 緩衝區列表指令

:buffers :buffers 或 :files 列出所有已知的緩衝區和檔案名稱
:ball :ball 或 :sball 編輯所有引數/緩衝區 :unhide :unhide 或 :sunhide 編輯所有已載入的緩衝區
:badd :badd {fname} 將檔案名稱 {fname} 新增至列表 :bunload :bunload[!] [N] 從記憶體卸載緩衝區 [N] :bdelete :bdelete[!] [N] 卸載緩衝區 [N] 並從緩衝區列表中刪除
在目前視窗 在新視窗
:buffer :[N]buffer [N] :[N]sbuffer [N] 至引數/緩衝區 N :bnext :[N]bnext [N] :[N]sbnext [N] 至第 N 個下一個引數/緩衝區 :bNext :[N]bNext [N] :[N]sbNext [N] 至第 N 個上一個引數/緩衝區 :bprevious :[N]bprevious [N] :[N]sbprevious [N] 至第 N 個上一個引數/緩衝區 :bfirst :bfirst :sbfirst 至第一個引數/緩衝區 :blast :blast :sblast 至最後一個引數/緩衝區 :bmodified :[N]bmod [N] :[N]sbmod [N] 至第 N 個已修改的緩衝區

Q_sy 語法突顯

:syn-on :syntax on 開始使用語法突顯 :syn-off :syntax off 停止使用語法突顯
:syn-keyword :syntax keyword {group-name} {keyword} .. 新增語法關鍵字項目 :syn-match :syntax match {group-name} {pattern} ... 新增語法匹配項目 :syn-region :syntax region {group-name} {pattern} ... 新增語法區域項目 :syn-sync :syntax sync [ccomment | lines {N} | ...] 告知語法如何同步 :syntax :syntax [list] 列出目前的語法項目 :syn-clear :syntax clear 清除所有語法資訊
:highlight :highlight clear 清除所有突顯資訊 :highlight :highlight {group-name} {key}={arg} .. 設定 {group-name} 的突顯
:filetype :filetype on 開啟檔案類型偵測,但不包含語法突顯 :filetype :filetype plugin indent on 開啟檔案類型偵測,包含自動縮排和設定

Q_gu GUI 指令

:menu :menu 列出所有選單 :menu :menu {mpath} 列出以 {mpath} 開頭的選單 :menu :menu {mpath} {rhs} 新增選單 {mpath},給定 {rhs} :menu :menu {pri} {mpath} {rhs} 同上,但包含優先順序 {pri} :menu :menu ToolBar.{name} {rhs} 新增工具列項目,給定 {rhs} :tmenu :tmenu {mpath} {text} 將工具提示新增至選單 {mpath} :unmenu :unmenu {mpath} 移除選單 {mpath}

Q_fo 折疊

'foldmethod' set foldmethod=manual 手動折疊 set foldmethod=indent 依縮排折疊 set foldmethod=expr 依 'foldexpr' 折疊 set foldmethod=syntax 依語法區域折疊 set foldmethod=marker 依 'foldmarker' 折疊
zf zf{motion} 運算子:手動定義折疊 :fold :{range}fold 為 {range} 行定義折疊 zd zd 刪除游標下的一個折疊 zD zD 刪除游標下的所有折疊
zo zo 開啟游標下的一個折疊 zO zO 開啟游標下的所有折疊 zc zc 關閉游標下的一個折疊 zC zC 關閉游標下的所有折疊
zm zm 折疊更多:減少 'foldlevel' zM zM 關閉所有折疊:將 'foldlevel' 設為零 zr zr 減少折疊:增加 'foldlevel' zR zR 開啟所有折疊:將 'foldlevel' 設為最大值。
zn zn 不折疊:重設 'foldenable' zN zN 折疊正常設定 'foldenable' zi zi 反轉 'foldenable'
主要
命令索引
快速參考