technomancy/emacs-starter-kit — Issue #106: Feature Request: Increment/Decrement Number
Author: milkypostman
Created: 2011-11-10 22:05:06+00:00
State: open

I think this is a worthwhile addition. Maybe not.

```emacs-lisp
(global-set-key (kbd "C-c +") 'esk-increment-number-at-point)
(global-set-key (kbd "C-c -") 'esk-decrement-number-at-point)

(defun esk-increment-number-at-point ()
(interactive)
(skip-chars-backward "0123456789")
(or (looking-at "[0123456789]+")
(error "No number at point"))
(replace-match (number-to-string (1+ (string-to-number (match-string 0))))))

(defun esk-decrement-number-at-point ()
(interactive)
(skip-chars-backward "0123456789")
(or (looking-at "[0123456789]+")
(error "No number at point"))
(replace-match (number-to-string (1- (string-to-number (match-string 0))))))

```