- Increment / Decrement binary, octal, decimal and hex literals.
- Works like
C-a/C-xin VIM, i.e. searches for number up toeoland then increments or decrements. - 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-xin VIM. - Optionally keep zero padding (off by default).
- Decimal, e.g.
42,-17,+5,007. - Binary, e.g.
0b0101,0B0101. - Octal, e.g.
0o755,0O700. - Hexadecimal, e.g.
0xDEADBEEF,0XCAFE. - Unicode superscript and subscript, e.g.
²and₁.
Once this package is installed, all you need to do is bind keys to
evil-numbers/inc-at-pt and evil-numbers/dec-at-pt.
Position cursor over or before the literal and play with your numbers!
You may also want to bind keys to the incremental versions of these functions.
evil-numbers-pad-default-
Set to
tif you want numbers to be padded with zeros (numbers with a leading zero are always padded). If you want both behaviors, all commands take an optional argumentpadded. evil-numbers-separator-chars-
This option to support separator characters, set to “_” or “,” to support numeric literals such as:
16_777_216or4,294,967,296.You may wish to set this as a buffer local variable to enable this only for languages that support separators.
evil-numbers-case-
The case to use for hexadecimal numbers.
nilCurrent case (default).- ‘
upcaseAlways upper case. - ‘
downcaseAlways lower case.
evil-numbers-use-cursor-at-end-of-number-
Support matching numbers directly before the cursor.
This is off by default as it doesn’t follow VIM’s behavior.
evil-numbers-negative-
Configure negative number support.
tSupport negative numbers (default).nilNumbers negative prefix is ignored, useful when numbers may be date/year ranges.
Example key bindings:
(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 & visual states:
(evil-define-key '(normal visual) 'global (kbd "C-c +") 'evil-numbers/inc-at-pt)
(evil-define-key '(normal visual) 'global (kbd "C-c -") 'evil-numbers/dec-at-pt)
(evil-define-key '(normal visual) 'global (kbd "C-c C-+") 'evil-numbers/inc-at-pt-incremental)
(evil-define-key '(normal visual) 'global (kbd "C-c C--") 'evil-numbers/dec-at-pt-incremental)Keypad + and - present an alternative that can be directly bound without shadowing the regular + and -:
(evil-define-key '(normal visual) 'global (kbd "<kp-add>") 'evil-numbers/inc-at-pt)
(evil-define-key '(normal visual) 'global (kbd "<kp-subtract>") 'evil-numbers/dec-at-pt)
(evil-define-key '(normal visual) 'global (kbd "C-<kp-add>") 'evil-numbers/inc-at-pt-incremental)
(evil-define-key '(normal visual) 'global (kbd "C-<kp-subtract>") 'evil-numbers/dec-at-pt-incremental)This package requires the shift-number package, which provides the core number manipulation logic.
Put in load-path, (require 'evil-numbers) and set key bindings.
Assuming you have the melpa repository enabled, use-package can be used as follows.
The shift-number dependency will be installed automatically.
(use-package evil-numbers)See https://github.com/juliapath/evil-numbers/issues
- Matthew Fidler <matthew.fidler@gmail.com>
- Michael Markert <markert.michael@gmail.com>
- Julia Path <julia@jpath.de>
- Campbell Barton <ideasman42@gmail.com>