I want to replace all occurrences of a word in a file with a partial match. For example, search using "75008" and replace entire word with "12345678901"
Actual content
75003681846 75008494799 75213014616
75003681846 75008494795 75213014613
75003681846 75008513200 75213014614
75003681846 75008494798 75213014617
Expected content after replace
75003681846 12345678901 75213014616
75003681846 12345678901 75213014613
75003681846 12345678901 75213014614
75003681846 12345678901 75213014617
How to do it in vim
Thanks Red Ant
\< and \> match word boundaries.
\S* matches all non-whitespace.
s does substitution.
% applies it to the entire file.
:%s/\<\S*75008\S*\>/12345678901/g