zoukankan      html  css  js  c++  java
  • VIM 使用 匹配替换命令配合表达式 实现 递增替换

    :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!
    ");
     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!
    ");
     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!
    ");
     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!
    ");
     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!
    ");
     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!
    ");
     39                 g_counter += 2;
     40                 sleep(1);
     41         }
     42         return NULL;
    
  • 相关阅读:
    如何向线程传递参数
    IntelliJ IDEA 13 Keygen
    单链表的基本操作
    顺序表静态查找
    有向图的十字链表表存储表示
    BF-KMP 算法
    图的邻接表存储表示(C)
    二叉树的基本操作(C)
    VC远控(三)磁盘显示
    Android 数独游戏 记录
  • 原文地址:https://www.cnblogs.com/shaivas/p/7632021.html
Copyright © 2011-2022 走看看