码迷,mamicode.com
首页 > 系统相关 > 详细

VIM 使用 匹配替换命令配合表达式 实现 递增替换

时间:2017-10-06 19:37:00      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:cpp   ret   cti   使用   匹配   after   print   bsp   turn   

:let n=100 | g/while/s/\d/\=n / | let n=n+1

before

10 void *thread_function_1(void *arg) {
 11         int i;
 12         while(1)
 13         {
 14                 printf("Thread 1 says hi!\n");
 15                 g_counter += 1;
 16                 sleep(1);
 17         }
 18         return NULL;
 19 }
 20 
 21 void *thread_function_2(void *arg) {
 22         int i;
 23 
 24         while(1)
 25         {
 26                 printf("Thread 2 says hi!\n");
 27                 g_counter += 2;
 28                 sleep(1);
 29         }
 30         return NULL;
 31 }
 32 
 33 void *thread_function_3(void *arg) {
 34         int i;
 35 
 36         while(1)
 37         {
 38                 printf("Thread 3 says hi!\n");
 39                 g_counter += 2;
 40                 sleep(1);
 41         }
 42         return NULL;

 

after:

 

10 void *thread_function_1(void *arg) {
 11         int i;
 12         while(1)
 13         {
 14                 printf("Thread 1 says hi!\n");
 15                 g_counter += 1;
 16                 sleep(1);
 17         }
 18         return NULL;
 19 }
 20 
 21 void *thread_function_2(void *arg) {
 22         int i;
 23 
 24         while(1)
 25         {
 26                 printf("Thread 2 says hi!\n");
 27                 g_counter += 2;
 28                 sleep(1);
 29         }
 30         return NULL;
 31 }
 32 
 33 void *thread_function_3(void *arg) {
 34         int i;
 35 
 36         while(1)
 37         {
 38                 printf("Thread 3 says hi!\n");
 39                 g_counter += 2;
 40                 sleep(1);
 41         }
 42         return NULL;

 

VIM 使用 匹配替换命令配合表达式 实现 递增替换

标签:cpp   ret   cti   使用   匹配   after   print   bsp   turn   

原文地址:http://www.cnblogs.com/shaivas/p/7632021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!