这里有50个有用的Vim命令,在正常模式下工作。这些可以再次组合形成新的命令。使用他们能极大的提升你的工作效率。排名不分先后:
-
gg
移动到文件的第一行 -
G
移到最后一行 -
gg=G
选择整个文件 -
gv
回到最后一次定位 - ``<` 跳到最后一个视觉选择的开始Jump to beginning of last visual selection
- ``>` Jump to end of last visual selection
-
^
Move to first non-blank character of the line -
g_
Move the last non-blank character of the line (but you remove trailing whitespace, right) -
g_lD
Delete all the trailing whitespace on the line -
ea
Append to the end of the current word -
gf
Jump to the file name under the cursor -
xp
Swap character forward -
Xp
Swap character backward -
yyp
Duplicate the current line -
yapP
Duplicate the current paragraph -
dat
Delete around an HTML tag, including the tag -
dit
Delete inside an HTML tag, excluding the tag -
w
Move one word to the right -
b
Move one word to the left -
dd
Delete the current line -
zc
Close current fold -
zo
Open current fold -
za
Toggle current fold -
zi
Toggle folding entirely -
<<
Outdent current line -
>>
Indent current line -
z=
Show spelling corrections -
zg
Add to spelling dictionary -
zw
Remove from spelling dictionary -
~
Toggle case of current character -
gUw
Uppercase until end of word (u for lower, ~ to toggle) -
gUiw
Uppercase entire word (u for lower, ~ to toggle) -
gUU
Uppercase entire line -
gu$
Lowercase until the end of the line -
da"
Delete the next double-quoted string -
+
Move to the first non-whitespace character of the next line -
S
Delete current line and go into insert mode -
I
insert at the beginning of the line -
ci"
Change what’s inside the next double-quoted string -
ca{
Change inside the curly braces (try [, (, etc.) -
vaw
Visually select word -
dap
Delete the whole paragraph -
r
Replace a character - ``[` Jump to beginning of last yanked text
- ``]` Jump to end of last yanked text
-
g;
Jump to the last change you made -
g,
Jump back forward through the change list -
&
Repeat last substitution on current line -
g&
Repeat last substitution on all lines -
ZZ
Save the current file and close it