Linux中vi的使用方法

Linux的vi工作方式

1.[root@linux root]# cat fil1
[root@linux root]# cat > fil1
this is fil1
that is fil1
who is fil1
[root@linux root]#
2. [root@linux root]# cat fil1
[root@linux root]# cat > fil1
this is fil1
that is fil1
who is fil1
[root@linux root]# vi fil1
3.i或I插入
this is file2 this is fil1
that is fil1
who is fil1
~
– 插入 –
3.Esc(退出)
4.u或U(恢復)
this is fil1
that is fil1
who is fil1
5.dd(刪除一行)
that is fil1
who is fil1
6.dw(刪除一個字)
is fil1
that is fil1
who is fil1
7.cc(刪除一行,並轉爲輸入狀態)
|
that is fil1
who is fil1
8.:w 保存命令
:q 退出
:q! 強制退出
:wq 保存並退出
:u 退出
9.rs 替換當前字符
shis is fil1
that is fil1
who is fil1
10.注:k爲數字
(k)yw 複製一個字
this this this is fil1
that is fil1
who is fil1

(k)yy 複製一個行
this is fil1
this is fil1
that is fil1
who is fil1

(k)p 粘貼(粘貼幾次)
11.a~Z寄存器
”ap “ayw this a
“bp “byw fil1 b
“cp “cyy who is fil1 c
注: 2”cyw 2個字
6”cp 複製六遍
12.[root@linux root]# ls
anaconda-ks.cfg fil1 fil2 fil3 fil4 fil5
[root@linux root]#
13. this is file
that is fil1
who is fil1
:n fil2
14. 22222222222
22222222222
22222222222
“fil2” [已轉換] 3L, 36C
15. this is file
that is fil1
that is fil1
that is fil1
that is fil1
that is fil1
that is fil1
that is fil1
who is fil1
/that (查找that字符串)n向前查找 N 向後查找 注:?則相反
16. this is file
that is fil1
who is fil1
:w fil6 (另存爲fil6未存在)
17. this is file
that is fil1
who is fil1
:w! fil6 (另存爲fil6 存在)
18. this is file
that is fil1
who is fil1
十月 2019
日 一 二 三 四 五 六
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
:r! cal (指定行添加日曆)
19. Whis is file
WhaW is fil1
who is fil1
:1 ,$ s/t/W/g (全局替換)
20. Whis is file
that is fil1
who is fil1
:g/t/s//W//gc (一個一個替換)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章