Alex Rivera | Logout

vim regex increment all numbers by 1

Asked 2012-05-02T20:01:17.297
45

I have a prepared statement in java that i am adding an argument to the front of. Long story short, I have to take a ton of set methods and increment their first argument by 1.

I'd like a quick way to do a search and replace matching all numbers, and then increment them by one.

Edit
Report

1 Answer

70

Figured it out.

%s/\d\+/\=(submatch(0)+1)/g

http://vim.wikia.com/wiki/Using_an_expression_in_substitute_command

answered 2012-05-02T20:14:54.763

Your Answer