您的位置:首页 > 运维架构 > Linux

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

2017-10-31 10:23 483 查看
进入编辑模式
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 相反
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux 基础