Evil Numbers

Increment / Decrement binary, octal, decimal and hex literals

works like C-a/C-x in vim, i.e. searches for number up to eol and then increments or decrements

Can keep zero padding up (off by default)

When a region is active, as in evil’s visual mode, all the numbers within that region will be incremented/decremented (unlike in vim)

Increment/decrement numbers incrementally like g C-a/g C-x in vim.

Detected Literals

binary, e.g. 0b0101 , 0B0101

, octal, e.g. 0o755 , 0O700

, hexadecimal, e.g. 0xDEADBEEF , 0XCAFE

, unicode superscript and subscript, e.g. ² and ₁ .

Install

Put in load-path , (require 'evil-numbers) and bind, for example:

( global-set-key ( kbd " C-c + " ) 'evil-numbers/inc-at-pt ) ( global-set-key ( kbd " C-c - " ) 'evil-numbers/dec-at-pt ) ( global-set-key ( kbd " C-c C-+ " ) 'evil-numbers/inc-at-pt-incremental ) ( global-set-key ( kbd " C-c C-- " ) 'evil-numbers/dec-at-pt-incremental )

or only in evil’s normal state:

( define-key evil-normal-state-map ( kbd " C-c + " ) 'evil-numbers/inc-at-pt ) ( define-key evil-normal-state-map ( kbd " C-c - " ) 'evil-numbers/dec-at-pt ) ( define-key evil-normal-state-map ( kbd " C-c C-+ " ) 'evil-numbers/inc-at-pt-incremental ) ( define-key evil-normal-state-map ( kbd " C-c C-- " ) 'evil-numbers/dec-at-pt-incremental )

For window system users the keypad + and - present an alternative that can be directly bound without shadowing the regular + and - :

( define-key evil-normal-state-map ( kbd " <kp-add> " ) 'evil-numbers/inc-at-pt ) ( define-key evil-normal-state-map ( kbd " <kp-subtract> " ) 'evil-numbers/dec-at-pt ) ( define-key evil-normal-state-map ( kbd " C-<kp-add> " ) 'evil-numbers/inc-at-pt-incremental ) ( define-key evil-normal-state-map ( kbd " C-<kp-subtract> " ) 'evil-numbers/dec-at-pt-incremental )

Set evil-numbers/padDefault to t if you want numbers to be padded with zeros (numbers with a leading zero are always padded). If you want both behaviours, all commands take an optional argument padded .

Usage

Position cursor on literal and play with your numbers!

Known Bugs

See http://github.com/janpath/evil-numbers/issues

Contributors