Quick guide for Vim
๐ฆพ
:w
save file,but don't quit:wq
write quit:x
same as :wq
q!
quit without saveZZ
save file and quitH
move to top of screenM
move to middle of screenL
move to bottom of screenw
jump forwards to the start of a worde
jump forwards to the end of a word0
go to start of line$
go to end of lineb
go to previous wordgg
first line of fileGG
last line of file{
jump to next paragraph}
jump tp previous paragraphzz
center cursor on screenctrl-d
move foward 1/2 screenctrl-u
move back 1/2 screeni
insert before the cursorI
insert at the beginning of the linea
insert (append) after the cursorA
insert (append) at the end of the lineo
append (open) a new line below the current lineO
append (open) a new line above the current lineCtrl-o
Ctrl-o
escapes user to do one normal-mode command, and then return to the insert mode. The same effect can be achieved by <ESC>
ing to normal mode, doing the single command and then entering back to insert mode.Ctrl-o a
go to outside of the bracketctrl-p
auto compelete previous words (ctrl-p
for previous , ctrl-n
for next)/Word
search for 'Word'n
move to next 'Word'N
move to previous 'Word'noh[lsearch]
remove highlighting of search matchesv
VisualV
Visual Lineaw
mark a worda(
mark a block with ()a{
mark a block with {}a[
mark a block with []a<
mark a block with <>i(
mark a inner block with ()same as
{}
,[]
,<>
, etc..
yy
yank (copy) a linep
pasteu
undoctrl-r
redor
replace a single character.R
replace more than one character, until ESC
is pressed.J
join line below to the current one with one space in betweenc
stand for change (delete and move to insert mode )C
change to endsp file_name
open a file in a new buffer and split window:term
open terminal in split windowvert
edit all buffers as vertical windowsvert sp a.cpp
below
opem windows belowbelow term
ctrl-ww
switch windowsctrl-wh
switch to left windows (vertical split)ctrl-wl
switch to right windows (vertical split)ctrl-wj
switch to windows below(horizontal split)ctrl-wk
switch to windows above(horizontal split)ctrl-wx
exchange current window with next oneresize 20
resize height of window ,change the height to 20 rows.res 20
short cut of resizeres +5
,res -5
increase/decrease heightvert res 30
resize the width of window:term ctrl-wx res 35
,open terminal and switch window ,resize window of Vim in to height of 35 rows.bd
buffer delete(close file)ctrl \ n
go to normal mode in terminal ( i
for go back to terminal )tab sp file_name
open file in new tab:tabs
list all tabs including their displayed windowstabn
, gt
go to next tabtabp
, gT
go to previous tabctrl-PgDn
, Ctrl-PgUp
switch tabsVim
Note