免費轉換器

Vim 指令 速查表

全面的 Vim 指令速查表。搜尋 80 多個核心 Vim 指令,附帶範例、說明和一鍵複製功能。

i
Enter Insert mode before the cursor
範例:i
I
Enter Insert mode at the beginning of the line
範例:I
a
Enter Insert mode after the cursor
範例:a
A
Enter Insert mode at the end of the line
範例:A
o
Open a new line below and enter Insert mode
範例:o
O
Open a new line above and enter Insert mode
範例:O
v
Enter Visual mode (character selection)
範例:v
V
Enter Visual Line mode (line selection)
範例:V
Ctrl+v
Enter Visual Block mode (column selection)
範例:Ctrl+v
:
Enter Command-line mode
範例::w
Esc
Return to Normal mode from any mode
範例:Esc
R
Enter Replace mode (overwrite characters)
範例:R
h
Move cursor left
範例:5h
j
Move cursor down
範例:10j
k
Move cursor up
範例:10k
l
Move cursor right
範例:5l
w
Move to the start of the next word
範例:3w
b
Move to the start of the previous word
範例:3b
e
Move to the end of the current word
範例:2e
0
Move to the beginning of the line
範例:0
^
Move to the first non-blank character of the line
範例:^
$
Move to the end of the line
範例:$
gg
Move to the first line of the file
範例:gg
G
Move to the last line of the file
範例:G
:N
Jump to line number N
範例::42
Ctrl+f
Scroll forward (down) one screen
範例:Ctrl+f
Ctrl+b
Scroll backward (up) one screen
範例:Ctrl+b
Ctrl+d
Scroll down half a screen
範例:Ctrl+d
Ctrl+u
Scroll up half a screen
範例:Ctrl+u
H
Move cursor to the top of the screen
範例:H
M
Move cursor to the middle of the screen
範例:M
L
Move cursor to the bottom of the screen
範例:L
%
Jump to matching bracket, parenthesis, or brace
範例:%
x
Delete the character under the cursor
範例:x
dd
Delete (cut) the current line
範例:dd
dw
Delete from cursor to the end of the word
範例:dw
d$
Delete from cursor to the end of the line
範例:d$
D
Delete from cursor to end of line (same as d$)
範例:D
yy
Yank (copy) the current line
範例:yy
yw
Yank (copy) from cursor to end of word
範例:yw
p
Paste after the cursor
範例:p
P
Paste before the cursor
範例:P
u
Undo the last change
範例:u
Ctrl+r
Redo the last undone change
範例:Ctrl+r
cc
Change (delete and enter insert mode) the current line
範例:cc
cw
Change from cursor to end of word
範例:cw
c$
Change from cursor to end of line
範例:c$
.
Repeat the last change
範例:.
>>
Indent the current line one level to the right
範例:>>
<<
Unindent the current line one level to the left
範例:<<
==
Auto-indent the current line
範例:==
J
Join the current line with the line below
範例:J
~
Toggle case of character under cursor
範例:~
r{char}
Replace the character under the cursor with {char}
範例:ra
/{pattern}
Search forward for pattern
範例:/foo
?{pattern}
Search backward for pattern
範例:?foo
n
Repeat the last search in the same direction
範例:n
N
Repeat the last search in the opposite direction
範例:N
*
Search forward for the word under the cursor
範例:*
#
Search backward for the word under the cursor
範例:#
:s/old/new/g
Replace all occurrences of old with new on the current line
範例::s/foo/bar/g
:%s/old/new/g
Replace all occurrences of old with new in the whole file
範例::%s/foo/bar/g
:%s/old/new/gc
Replace all with confirmation prompts
範例::%s/foo/bar/gc
:noh
Clear the search highlight
範例::noh
:w
Save the current file
範例::w
:w filename
Save the current buffer as a new filename
範例::w newfile.txt
:q
Quit (close the window)
範例::q
:wq
Save and quit
範例::wq
:q!
Quit without saving (force quit)
範例::q!
:x
Save and quit (only writes if changes were made)
範例::x
:e filename
Open a file for editing
範例::e README.md
:sp
Split the window horizontally
範例::sp file.txt
:vsp
Split the window vertically
範例::vsp file.txt
Ctrl+w+w
Switch focus to the next split window
範例:Ctrl+w w
Ctrl+w+h/j/k/l
Move focus to the window in the given direction
範例:Ctrl+w l
:close
Close the current window split
範例::close
:only
Close all windows except the current one
範例::only
:bn
Switch to the next buffer
範例::bn
:bp
Switch to the previous buffer
範例::bp
:bd
Delete (close) the current buffer
範例::bd
:ls
List all open buffers
範例::ls
:b N
Switch to buffer number N
範例::b 2
:tabnew
Open a new tab
範例::tabnew file.txt
:tabn
Switch to the next tab
範例::tabn
:tabp
Switch to the previous tab
範例::tabp
:tabclose
Close the current tab
範例::tabclose
gt
Go to the next tab
範例:gt
gT
Go to the previous tab
範例:gT
q{a-z}
Start recording a macro into register {a-z}
範例:qq
q (stop)
Stop recording the current macro
範例:q
@{a-z}
Execute the macro stored in register {a-z}
範例:@q
@@
Repeat the last executed macro
範例:@@
N@{a-z}
Execute macro N times
範例:5@q
:reg
Show the contents of all registers
範例::reg
v then d
Select text in Visual mode then delete it
範例:vwd
v then y
Select text in Visual mode then yank (copy) it
範例:vwy
v then c
Select text in Visual mode then change it
範例:vwc
v then >
Indent selected text to the right
範例:vip>
vip
Select the current paragraph in Visual mode
範例:vip
viw
Select the current word in Visual mode
範例:viw
vis
Select the current sentence in Visual mode
範例:vis
V then J
Select lines in Visual Line mode then join them
範例:VjJ
:set number
Show line numbers
範例::set number
:set nonumber
Hide line numbers
範例::set nonumber
:syntax on
Enable syntax highlighting
範例::syntax on
:colorscheme
Change the color scheme
範例::colorscheme desert
:help {topic}
Open Vim help for a topic
範例::help :w
m{a-z}
Set a mark at the current cursor position
範例:ma
'{a-z}
Jump to the line of a mark
範例:'a
`{a-z}
Jump to the exact position of a mark
範例:`a
:set paste
Enable paste mode to avoid auto-indent issues
範例::set paste
:set ignorecase
Make searches case-insensitive
範例::set ignorecase
:set hlsearch
Highlight all search matches
範例::set hlsearch
ga
Show the ASCII value of the character under the cursor
範例:ga
zz
Center the current line on the screen
範例:zz
Ctrl+g
Show the current file name and cursor position
範例:Ctrl+g

關於此工具

vim 指令的綜合快速參考指南。瀏覽按類別組織的常用指令、語法和範例。可搜尋且適合行動裝置 - 將此頁面加入書籤,以便在需要快速提醒時即時存取。

使用方法

  1. 瀏覽分類的參考部分。
  2. 使用搜尋欄尋找特定指令或語法。
  3. 按一下任何條目即可查看使用範例和說明。
  4. 直接複製命令以在終端機或編輯器中使用。

常見問題

該參考文獻是最新的嗎?
該參考涵蓋了廣泛使用的命令和語法,這些命令和語法在各個版本中都是穩定的。有關最新添加或特定於版本的功能,請查看官方文件。
我可以離線使用嗎?
加載後,該頁面無需互聯網連接即可運行。將其新增為書籤以便快速存取 - 所有內容都在瀏覽器中呈現,無需進一步的網路請求。
這是全面的還是只是基礎知識?
它涵蓋了處理 90% 日常任務的最常用命令和模式。有關利基或高級功能,請參閱官方文件。
我可以建議補充嗎?
我們定期更新我們的參考資料。如果您發現缺少命令或有建議,請透過我們的聯絡頁面告知我們。