Here is a simple introduction to the vim of the search and replace, it is well known that VIM support for regular expressions is very good, for programmers in the analysis of large amounts of data, the use of VIM this function is undoubtedly a weapon.
First of all, we need to understand some of the special meanings of vim:
^ Represents the beginning of the line
$ represents end of line
\d Representative Numbers
\d represents non-digital
[x, Y, z]: represents various conditions of choice
OK, so let's go over a few common topics and try it out:
1. Delete rows beginning with a number
%S/^\D.*$//IGC: Put this line into space
%S/^\D.*$\N//IGC: Delete this line directly, including the newline character, (note that it is \ n, not \ r \ n, because this is for the Linux platform, the next line will go to this line)
2. Delete the line starting with the number 3 or 4 or a
%S/^[3,4,A].*$//IGC: Set this line to empty
3.
1 IP 202.114.1.1.23444
2 IP 202.114.1.2.wokao
3 IP 202.114.1.3.woai23444
The request finally becomes
202.114.1.1
202.114.1.2
202.114.1.3
You can do this in the following order:
%s/\d.*ip//IGC
%s/\.\d*$//igc
%s/\.\d.*$//igc
Vim Simple Find and replace