1. 程式人生 > >進入編輯模式、vim命令模式、vim實踐

進入編輯模式、vim命令模式、vim實踐

linux 基礎

進入編輯模式

1、[root@test ~]# vi /etc/services

2、輸入小寫的i後再下發就會出現--INSERT--,就可以編輯

#

# Each line describes one service, and is of the form:

#

# service-name port/protocol [aliases ...] [# comment]


-- INSERT --


3、可以在光標下新增一行,用小寫的o


vim命令模式

1、查找

/even

# Each line describes one service, and is of the form:


#

# service-name port/protocol [aliases ...] [# comment]

/even


2、按n選擇下一個(向下查找)

3、輸入?even 選擇n向前查找

4、將所有的even字符替換成test,若是不加g的話,就只替換第一行

:1,$s/enev/test/g

5、:1,955s/zserv/test/g,在1行到955行替換


vim實踐

1、[root@test ~]# cp /etc/services /temp/1.txt

2、需要查看45行

:45

3、刪除一行

dd

刪除3行

3dd

4、還原上一步

u

5、移動到最後一行

G

6、移動到行首

gg

7、復制2行

2yy

8、粘貼

p

9、按u恢復上一步,按Ctrl+r 相反

本文出自 “探索發現新事物” 博客,請務必保留此出處http://shenj.blog.51cto.com/5802843/1977698

進入編輯模式、vim命令模式、vim實踐