Share 30 common Vim commands, which hopes to have twelve let you find it useful.
-
Delete characters from the cursor position to the end of a word and enter insert mode:
cw
. -
Delete word under the cursor and enter insert mode:
ciw
delete the word at the cursor position and space:daw
. -
Highlight the contents of the internal Tags:
vit
. -
The beginning of the move forward to the next word:
w
reverse move to the beginning of the current word / the last word:b
. -
Move to the n-th column of the current row:
n|
. -
Redraw the screen and display the current line in the middle of the window:
zz
. -
The cursor is moved to the top line of the window:
zt
the cursor to the bottom line of the window:zb
. -
Jump forward Vim Location:
<Ctrl-i>
Jump back Location:<Ctrl-0>
, browser-like forward and back functions. -
Jump back to the previous position:
''
back to the last editing position:'.
. -
Repeat the last Vim command line mode command:
@:
. -
View the current Vim file to open the file name, location and status information such as:
<Ctrl-g>
(g simultaneously press the Ctrl key and key). -
Under Vim command line mode,
%
it represents the full file path to the currently active buffer corresponding file. -
Does not leave insert mode, paste text register:
<C-r>{register}
(Register {} is the name of the register we want to insert). -
Reselection time by the visual range of the text mode is selected:
gv
. -
In Vim visual mode highlight region after pressing
:
the key, the command line will be filled with a predetermined range:'<,'>
representative of the range of the highlighted selection. -
The contents of any register is inserted into the command line:
:<Ctrl-r>{register}
. -
Press the insert mode
<Ctrl-r>
, the enter =, enter any arithmetic formula (e.g., 333 * 2), carriage return, you can see the operation result (which is the use of the expression register Vim"=
). -
Read-only register
"%
indicates the current active file Vim buffer file name, Vim in insert mode, press<Ctrl-r>%
can be entered into the file name of the current file. -
The current word insertion cursor Vim command line:
<Ctrl-r><Ctrl-w>
. -
Cursor line with
.
said last line of the file with the$
representation,%
the entire file (:1,$
short form). -
Delete the current cursor to the end of the line all the contents of the Bank:
d$
delete all the contents of the current cursor to the first line of the Bank:d0
. -
Delete all lines:
dG
or:%d
. -
After the exchange current cursor Vim two character sequence:
xp
. -
Auto indent current line alignment (also known as automatic formatting):
==
The current file is automatically aligned indent all lines:gg=G
. -
Forward next to the character {char} is located at the:
f{char}
, move forward to the next {char} is located at the front of a character:t{char}
. -
Under Normal mode Vim
;
commands to find duplicate lastf
character command looking for. -
Vim after a split screen to increase the height of the screen:
<Ctrl-w>+
(first press Ctrl key and w key, then press the + key). -
The word all files multiple tabs in food are replaced . Drink. , You can use the
tabdo
command::tabdo %s/food/drink/g
. -
Temporary exit insert mode to execute a single command and return to insert mode:
<Ctrl-o>
. -
Modify the character at the current cursor as A:
ra
. -
National Cheng Kung University to write the word:
gUiw
the current word to lower case:guiw
. -
Save as
:saveas <filename>
file: . -
Read the file and the contents of the cursor after insertion:
:r <filename>
. -
Fall back to 15 minutes before the contents of the file:
:earlier 15m
.