Chuyển đổi miễn phí

Lệnh Vim Bảng gian lận

Bảng cheat lệnh Vim toàn diện. Tìm kiếm hơn 80 lệnh Vim cần thiết kèm theo ví dụ, mô tả và sao chép chỉ bằng một cú nhấp chuột.

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

Về công cụ này

Hướng dẫn tham khảo nhanh toàn diện cho các lệnh vim. Duyệt qua các lệnh, cú pháp và ví dụ thường dùng được sắp xếp theo danh mục. Có thể tìm kiếm và thân thiện với thiết bị di động — đánh dấu trang này để truy cập ngay khi bạn cần lời nhắc nhanh.

Cách sử dụng

  1. Duyệt qua các phần tham khảo được phân loại.
  2. Sử dụng thanh tìm kiếm để tìm các lệnh hoặc cú pháp cụ thể.
  3. Nhấp vào bất kỳ mục nào để xem ví dụ sử dụng và giải thích.
  4. Sao chép lệnh trực tiếp để sử dụng trong terminal hoặc trình soạn thảo của bạn.

Câu hỏi thường gặp

Tài liệu tham khảo này có được cập nhật không?
Tài liệu tham khảo bao gồm các lệnh và cú pháp được sử dụng rộng rãi, ổn định trên các phiên bản. Để biết các bổ sung mới nhất hoặc các tính năng dành riêng cho phiên bản, hãy kiểm tra tài liệu chính thức.
Tôi có thể sử dụng tính năng này ngoại tuyến không?
Sau khi tải, trang hoạt động mà không cần kết nối internet. Đánh dấu nó để truy cập nhanh - tất cả nội dung được hiển thị trong trình duyệt mà không cần yêu cầu mạng thêm.
Đây có phải là toàn diện hay chỉ là những điều cơ bản?
Nó bao gồm các lệnh và mẫu được sử dụng phổ biến nhất để xử lý 90% công việc hàng ngày. Đối với các tính năng thích hợp hoặc nâng cao, hãy tham khảo tài liệu chính thức.
Tôi có thể đề xuất bổ sung không?
Chúng tôi thường xuyên cập nhật tài liệu tham khảo của chúng tôi. Nếu bạn nhận thấy các lệnh bị thiếu hoặc có đề xuất, hãy cho chúng tôi biết thông qua trang liên hệ của chúng tôi.