Three modes of vim editing artifact:
- Command mode
- Insert mode
- Last-line mode
$vim name +number Jump directly to the number line of the fileCommand mode, insert mode
i : Insert before current cursor
I : .... at the beginning of
A : Insert after current cursor
A : ..... At the end of your line
o : Insert next line
O: Previous line Insert Command -mode commands
dd : Delete the current row
n dd : Delete n rows continuously from the current line
D : Delete everything from behind the cursor
x : Delete the character of the cursor
X : The character before the cursor is deleted
yy : Copy the current line
n yy : Copy the current line to start a continuous n row
P : Start pasting from the next line where the cursor is located
R : Replace the character where the cursor is located
R : Replace the character before the cursor
>> : Indent the current line to the right
n >> : Indents the current line to the right by N-Grid
<< : Indent the current line to the left
n << : Indents the current line to the left N grid
G : To the last line of the file
GG : To the first line of the file
ctrl+r : Cancel Undo
u : Undo last-line mode
: Set number
: 1,4 >
: 1,4 <
: Wq Save and exit
: x Save and exit
: q! does not save exit Replace | In the last line mode:
:%s/replaced content/replace content/g replaceExample::
50,100s/man/man/g
to replace man in 50-100 rows with man
Vim edit artifact Common basic commands