Regex in VIM

1) The metacharacters
Regex in VIM_第1张图片

2)  The greedy qualifiers

Regex in VIM_第2张图片

3)  The non-greedy qualifiers

Regex in VIM_第3张图片

4) The ranges

[12345], [^"], [a-z], [-0-9], ...

5) The grouping and backreferences

Regex in VIM_第4张图片

6) The alternatives

Using "\|" you can combine several expressions into one which matches any of its components. The first one matched will be used.
The thing to remember about VIM alternation that it is not greedy. It won't search for the longest possible match, it will use the first that matched. That means that the order of the items in the alternation is important!


7) The operator precedence

Regex in VIM_第5张图片

8) The examples

(1) There is a file which contains the following lines, we need do the following:

abc => abc=abc
cde => cde=cde

Solution:
:%s/\(.\+\)/\1=\1/

(2)


你可能感兴趣的:(Regex in VIM)