I have a very large text file that I have opened it in VIM and I need to add 1 to numbers matching some criteria. for example:
Comment 1
Comment 2
[p2,0,0,115]Live! ConcertGrand
[p2,2,104,5]Live! PopGrand
[p2,3,104,4]Live! RockPiano
[p2,4,104,3]Live! AmbientPiano
End of file.
and I'd like to transform this (by adding say 1 to the second element of the list) to
Comment 1
Comment 2
[p2,1,0,115]Live! ConcertGrand
[p2,3,104,5]Live! PopGrand
[p2,4,104,4]Live! RockPiano
[p2,5,104,3]Live! AmbientPiano
End of file.
How can I do this in vim, please?
I have tried:
%s/\[p\zs\d\+\(,\d\+\)\=/\=(1+str2nr(submatch(1)))/
But it does not work. Any help would be greatly appreciated. CS