Increment/decrement numbers in visual-block mode

1 Point

Romain Lafourcade Romain Lafourcade

9 years ago

Like <C-a> and <C-x> in normal mode, but in visual mode.

-- <C-a> to increment by 1,

-- 5<C-x> to decrement by 5.

xnoremap <C-a> :<C-u>let vcount = v:count ? v:count : 1 <bar> '<,'>s/\%V\d\+/\=submatch(0) + vcount<cr>gv
xnoremap <C-x> :<C-u>let vcount = v:count ? v:count : 1 <bar> '<,'>s/\%V\d\+/\=submatch(0) - vcount<cr>gv