Vim’s search and replace capability is extensive. I’m sure I just use a fraction of it’s power on a regular basis. This post is where I’m keeping my notes on the various features that I often forget about.
-
Regular expression search and replace with substrings:
%s/a\(first\)b\(second\)c/d \1 \2 d/That’s just a normal search on any line of the file
% , searching for two substrings that we want to keep. The replacement string will be anything really, and use\1and\2 to put the substrings wherever we want.