HR's Blog

Swimming 🏊 in the sea🌊of code!

0%

vi常用明令入门

.

vim

1
2
3
4
5
6
:set number  //code line number
:qa! //quit allbutters force
:w //save file
:w anotherfile.txt //save to another file.
:e //edit another file.
contrl + g // show the file name you are editing.

Move

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
H(左) J(上) K(下) L(右)
number + H/J/K/L //move line number
w //move to next word of the begin
e //move to next word of the end
number + w //move to next number word
( //move to previous sentence
) //move to next sentence
[ //move to previous paragraph
] //move to next paragraph

G //End of the file
gg //begin of the file
control + F //Move forward page
control + B // Move backward page

:8 //go to the line 8
number8 + gg //go to the line 8
number8 + G //
$ //end of the line
0 //begin of the lline
vim filename.txt +8 //open the filename.txt line 8

Seach

1
2
3
/<contact>  //seaching
* //next word under cursor
# // previous word nuder cursor

delete

1
2
3
4
5
6
d + w  //first word delete
u //undo
d + ) // delete sentence
dd // delete a line
d /Genius //delete everthing up to genius
d + ) //dedete the sentence

copy and past

1
2
3
4
5
y + w //yank work.  copy
p //past after the cursor
P //past before the cursor
yy //copy the whole line
x //delete one character under the cursor

References