I have rather large files in which I need to substitute NX for N1 but only if the line already contains NX as a pattern. So far I do it manually by first searching for occurrences of NX with:
/NX
and then using
'<,'>s/N1/NX
But the files are really large and long and the chances of me making a mistake during this manual procedure are very high. Is there a way to do this more efficiently in Vim?
Here is an example of what a line in one of the files might look like:
S22Tg K1B12N1Tg D1AE22K5 K2B12N1Tg D1AE22K6 W01B12N1Tg D1AE22TDNXW01 W02B12N1Tg D1AE22TDNXW02 W03B12N1Tg
Note, that the lines are all very similar and only differ in terms of the numbers occurring after the letters.