Penukar Percuma

Perintah Vim Lembaran Cheat

Helaian cheat arahan Vim yang komprehensif. Cari 80+ arahan Vim penting dengan contoh, penerangan dan salinan satu klik.

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

Tentang alat ini

Panduan rujukan pantas yang komprehensif untuk arahan vim. Semak imbas arahan, sintaks dan contoh yang biasa digunakan yang disusun mengikut kategori. Boleh dicari dan mesra mudah alih — tandakan halaman ini untuk akses segera apabila anda memerlukan peringatan pantas.

Cara menggunakan

  1. Semak imbas bahagian rujukan yang dikategorikan.
  2. Gunakan bar carian untuk mencari arahan atau sintaks tertentu.
  3. Klik pada mana-mana entri untuk melihat contoh penggunaan dan penjelasan.
  4. Salin arahan terus untuk digunakan dalam terminal atau editor anda.

Soalan lazim

Adakah rujukan ini terkini?
Rujukan meliputi arahan dan sintaks yang digunakan secara meluas yang stabil merentas versi. Untuk penambahan terkini atau ciri khusus versi, semak dokumentasi rasmi.
Bolehkah saya menggunakan ini di luar talian?
Setelah dimuatkan, halaman berfungsi tanpa sambungan internet. Tandai halaman untuk akses pantas — semua kandungan dipaparkan dalam penyemak imbas tanpa permintaan rangkaian selanjutnya.
Adakah ini menyeluruh atau hanya asas?
Ia merangkumi arahan dan corak yang paling biasa digunakan yang mengendalikan 90% tugas harian. Untuk ciri khusus atau lanjutan, rujuk dokumentasi rasmi.
Bolehkah saya mencadangkan penambahan?
Kami sentiasa mengemas kini rujukan kami. Jika anda mendapati tiada arahan atau mempunyai cadangan, beritahu kami melalui halaman hubungan kami.