vim +'g/^/exe "norm! 3Wf=5\<C-A>"' +wq file
+ argument runs a series of normal mode operations on each line to increment the number 5 times. It uses a
:global command to run this on every line. Simply using
:normal with a range
%norm would be simpler if we weren't using CTRLA to increment the number, but in order to (easily) pass this control character into Vim we build the command as a string to run with
:execute, and thus we need the
The second + argument simply saves the file.
If the format of RANDOM TEXT is less regular (or if you just prefer regular expressions), you could instead use a
vim +'%s/num2=\zs\d\+/\=submatch(0) + 5' +wq file
This uses a
:substitute command to replace the
N part of
num2=N with the existing value plus five.