Replace all non-matching characters between specific columns
I am trying to replace all non-matching characters in one line between specific columns (after searching).
Example :
Search can be everything
In the example below, search = test
Alternative character of mismatched characters: blank space.
I want to replace all non-" test
" characters between columns 10 and 30.
Columns 10 and 30 are denoted by|
before: djd<aj.testjal.kjetestjaja testlala ratesttsuvtesta !<-a-
| |
after: djd<aj.test test testlala ratesttsuvtesta !<-a-
How can I figure this out?
source to share
One method could be to select an appropriate range of columns using visual mode (control + v)
Once selected, find and replace can be done with ( see this question )
%s/\%Vfoo/bar/g
A regex for no test can be found here: Regex to match a string that doesn't contain a word?
source to share