Given the following text in Vim:
[2] [3] [4]
I want to perform a search and replace and produce the following:
[1] [2] [3]
I know how to extract out the numbers using back-reference via search and replace:
:%s/\[\(\d\)\]/[\1]/g
But now the question is how do you go about decrementing the value of \1.
Any ideas?
Try
EDIT: I added a
\+after\din case you wanted to match more than single digit numbers.See :help sub-replace-special