免费转换器
Vim 命令 速查表
全面的 Vim 命令速查表。搜索 80 多个核心 Vim 命令,附带示例、说明和一键复制功能。
i
Enter Insert mode before the cursor
示例:
iI
Enter Insert mode at the beginning of the line
示例:
Ia
Enter Insert mode after the cursor
示例:
aA
Enter Insert mode at the end of the line
示例:
Ao
Open a new line below and enter Insert mode
示例:
oO
Open a new line above and enter Insert mode
示例:
Ov
Enter Visual mode (character selection)
示例:
vV
Enter Visual Line mode (line selection)
示例:
VCtrl+v
Enter Visual Block mode (column selection)
示例:
Ctrl+v:
Enter Command-line mode
示例:
:wEsc
Return to Normal mode from any mode
示例:
EscR
Enter Replace mode (overwrite characters)
示例:
Rh
Move cursor left
示例:
5hj
Move cursor down
示例:
10jk
Move cursor up
示例:
10kl
Move cursor right
示例:
5lw
Move to the start of the next word
示例:
3wb
Move to the start of the previous word
示例:
3be
Move to the end of the current word
示例:
2e0
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
示例:
ggG
Move to the last line of the file
示例:
G:N
Jump to line number N
示例:
:42Ctrl+f
Scroll forward (down) one screen
示例:
Ctrl+fCtrl+b
Scroll backward (up) one screen
示例:
Ctrl+bCtrl+d
Scroll down half a screen
示例:
Ctrl+dCtrl+u
Scroll up half a screen
示例:
Ctrl+uH
Move cursor to the top of the screen
示例:
HM
Move cursor to the middle of the screen
示例:
ML
Move cursor to the bottom of the screen
示例:
L%
Jump to matching bracket, parenthesis, or brace
示例:
%x
Delete the character under the cursor
示例:
xdd
Delete (cut) the current line
示例:
dddw
Delete from cursor to the end of the word
示例:
dwd$
Delete from cursor to the end of the line
示例:
d$D
Delete from cursor to end of line (same as d$)
示例:
Dyy
Yank (copy) the current line
示例:
yyyw
Yank (copy) from cursor to end of word
示例:
ywp
Paste after the cursor
示例:
pP
Paste before the cursor
示例:
Pu
Undo the last change
示例:
uCtrl+r
Redo the last undone change
示例:
Ctrl+rcc
Change (delete and enter insert mode) the current line
示例:
cccw
Change from cursor to end of word
示例:
cwc$
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
示例:
?foon
Repeat the last search in the same direction
示例:
nN
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.txtCtrl+w+w
Switch focus to the next split window
示例:
Ctrl+w wCtrl+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
示例:
:tabclosegt
Go to the next tab
示例:
gtgT
Go to the previous tab
示例:
gTq{a-z}
Start recording a macro into register {a-z}
示例:
qqq (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
示例:
:regv then d
Select text in Visual mode then delete it
示例:
vwdv then y
Select text in Visual mode then yank (copy) it
示例:
vwyv then c
Select text in Visual mode then change it
示例:
vwcv then >
Indent selected text to the right
示例:
vip>vip
Select the current paragraph in Visual mode
示例:
vipviw
Select the current word in Visual mode
示例:
viwvis
Select the current sentence in Visual mode
示例:
visV 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 :wm{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 hlsearchga
Show the ASCII value of the character under the cursor
示例:
gazz
Center the current line on the screen
示例:
zzCtrl+g
Show the current file name and cursor position
示例:
Ctrl+g