vivim 中如何在每行行首或行尾插入指定字符

vivim 中如何在每行行首或行尾插入指定字符,第1张

现在假设如是

nc10@your-5554c55be4 ~

$ cat sheet

server 127.0.0.1 localhost connected yes 12-3-08

server 127.0.0.1 localhost connected no 12-3-08

server 127.0.0.1 localhost connected yes 14-9-09

server 127.0.0.1 localhost connected yes 15-9-09

server 127.0.0.1 localhost connected no 16-9-09

nc10@your-5554c55be4 ~

$ sed '/^server.*$/s//&test/g' sheet

server 127.0.0.1 localhost connected yes 12-3-08 test

server 127.0.0.1 localhost connected no 12-3-08 test

server 127.0.0.1 localhost connected yes 14-9-09 test

server 127.0.0.1 localhost connected yes 15-9-09 test

server 127.0.0.1 localhost connected no 16-9-09 test

nc10@your-5554c55be4 ~

$

希望没理解错你的意思,呵呵

如果文件这样也可的,因为 /^server/ 限定了 只是行头是

server 才在行尾插入字符

user@minix-nb:~$ cat sheet

remote 127.0.0.1 localhost connected yes 12-3-08

server 127.0.0.1 localhost connected no 12-3-08

remote 127.0.0.1 localhost connected yes 14-9-09

server 127.0.0.1 localhost connected yes 15-9-09

remote 127.0.0.1 localhost connected no 16-9-09

user@minix-nb:~$ sed '/^server.*$/s//&test/g' sheet

remote 127.0.0.1 localhost connected yes 12-3-08

server 127.0.0.1 localhost connected no 12-3-08 test

remote 127.0.0.1 localhost connected yes 14-9-09

server 127.0.0.1 localhost connected yes 15-9-09 test

remote 127.0.0.1 localhost connected no 16-9-09

user@minix-nb:~$

现在假设如是

nc10@your-5554c55be4 ~

$ cat sheet

server 127.0.0.1 localhost connected yes 12-3-08

server 127.0.0.1 localhost connected no 12-3-08

server 127.0.0.1 localhost connected yes 14-9-09

server 127.0.0.1 localhost connected yes 15-9-09

server 127.0.0.1 localhost connected no 16-9-09

nc10@your-5554c55be4 ~

$ sed '/^server.*$/s//&test/g' sheet

server 127.0.0.1 localhost connected yes 12-3-08 test

server 127.0.0.1 localhost connected no 12-3-08 test

server 127.0.0.1 localhost connected yes 14-9-09 test

server 127.0.0.1 localhost connected yes 15-9-09 test

server 127.0.0.1 localhost connected no 16-9-09 test

nc10@your-5554c55be4 ~

$

希望没理解错你的意思,呵呵

如果文件这样也可的,因为 /^server/ 限定了 只是行头是

server 才在行尾插入字符

user@minix-nb:~$ cat sheet

remote 127.0.0.1 localhost connected yes 12-3-08

server 127.0.0.1 localhost connected no 12-3-08

remote 127.0.0.1 localhost connected yes 14-9-09

server 127.0.0.1 localhost connected yes 15-9-09

remote 127.0.0.1 localhost connected no 16-9-09

user@minix-nb:~$ sed '/^server.*$/s//&test/g' sheet

remote 127.0.0.1 localhost connected yes 12-3-08

server 127.0.0.1 localhost connected no 12-3-08 test

remote 127.0.0.1 localhost connected yes 14-9-09

server 127.0.0.1 localhost connected yes 15-9-09 test

remote 127.0.0.1 localhost connected no 16-9-09

user@minix-nb:~$

按键 *** 作

1、进入vi/vim编辑器,按CTRL+V进入可视化模式(VISUAL

BLOCK)

2、移动光标上移或者下移,选中多行的开头,如下图所示

3、选择完毕后,按大写的的I键,此时下方会提示进入“insert”模式,输入你要插入的注释符,例如#,

4、最后按ESC键,你就会发现多行代码已经被注释了

5、删除多行注释的方法,同样

Ctrl+v

进入列选择模式,移到光标把注释符选中,按下d,注释就被删除了。

以上就是专题栏小编带来的vim教程,更多教程请看“http://www.zhuantilan.com/zt/vim/”


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11269627.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存