I know this is a long shot, but I have a huge text file and I need to add a given number to other numbers matching some criteria.
Eg.
identifying text 1.1200
identifying text 1.1400
and I’d like to transform this (by adding say 1.15) to
identifying text 2.2700
identifying text 2.2900
Normally I’d do this in Python, but it’s on a Windows machine where I can’t install too many things. I’ve got Vim though 🙂
Here is a simplification and a fix on hobbs’ solution:
Thanks to
\zs, there is no need to recall the leading text. Thanks tostr2float()a single addition is done on the whole number (in other words, 1.15 + 2.87 will give the expected result, 4.02, and not 3.102).Of course this solution requires a recent version of Vim (7.3?)