且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

进入编辑模式、vim命令模式、vim实践

更新时间:2021-09-10 08:06:50

进入编辑模式

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 相反'












本文转自方向对了,就不怕路远了!51CTO博客,原文链接:http://blog.51cto.com/jacksoner/1977698 ,如需转载请自行联系原作者