首页 > 系统服务 > 详细

Replace using VIM, reuse part of the search pattern

时间:2018-02-07 19:12:28      阅读:190      评论:0      收藏:0      [点我收藏+]

参考:https://unix.stackexchange.com/questions/35206/replace-using-vim-reuse-part-of-the-search-pattern

 

 

\0 is the whole match. To use only part of it you need to set it like this and use \1

.s/(\([0-9]*\))/{\1}/

 

 

比如想把  文件里   test_12 test_2323  

等test_后面带数字的字符串,后面加一个x

变成test_12x   test_2323x

 

%s/\(test_\d\+\)/\0x/g

 

注意这里括号和+号都要加转义

 

Replace using VIM, reuse part of the search pattern

原文:https://www.cnblogs.com/brainstorm/p/8427295.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!