Some commands of VIM

Posted on 2021-11-19  412 Views


h-left  j-down  k-up  l-right
vim FILENAME
:q!         %exit and trash all changes
:wq         %save all changes
i           %insert
A           %append
dw          del to the next word
ddel to the end of a line
dd          del the whole line
2w          repeat a motion
operator    [number] motion
0           move to the start of the line
u           undo previous actions
U           undo all the changes on a line
CTRL-R      undo the undo's
p           put the deleted text after the cursor
r           replace the character under the cursor
ce          change to the end of the word
c          change to the end of the line
c [number] motion
CTRL-G      display of location and file status
G           move to the end of the file
number-G    move to the line number of the file
gg          move to the first line
/name       search the target with forward direction    tpy n to the next, N the opposite direction
?name       search the target with backward direction   tpy n to the next, N the opposite direction
CTRL-0      back to older position
CTRL-I      to the newer position
%           match the () or [] or {}
s/old/new   substitute
s/old/new/g substitute works in all line
#,#s/new/old/g    substitue between two #
%s/old/new/g  substitute for all in the file
%s/old/new/gc  substitute with confirmation
o                        open a line below and then insert
O                        open a line above
a                        insert after cursor
A                        insert after the end of the line
e                        move to the end of a word
y                        yanks(copy),after this then type p to paste
R                        enter Replace mode until ESC is pressed
set XXX                  set the option ``XXX´´ like [ic] for ignorecase, [is] for incsearch, [hls] for highlight
no                       no + option to switch an option off
F1, :help                       help
:help cmd                find help on cmd
:q                       close help window
:command CTRL-D          to see the possible completions, TAB to use one