How can I swap or replace multiple strings in code at the same time?

前端 未结 5 1313
北恋
北恋 2021-01-12 10:32

Given the following code sample:

uint8_t i, in, ni;
i = in = 2; ni = 1;
while (2 == i > ni) in++;

How can I replace i, in, and ni<

5条回答
  •  情深已故
    2021-01-12 11:17

    In vim you can have multiple commands, separated by |, so you could do your replacement with %s command:

    :%s/\/inni/ | %s/\/inin/ | %s/\/nini/
    

    Shortly what it means:

    %s/search/replacement/
    

    searches for given search pattern and replaces it with replacement;

    symbols "\<" and "\>" are standing here as word boundaries.

提交回复
热议问题