Created
April 26, 2013 02:42
-
-
Save sp3c73r2038/5464766 to your computer and use it in GitHub Desktop.
indent / unindent region of text in emacs, C/P from EmacsWiki
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun shift-text (distance) | |
(if (use-region-p) | |
(let ((mark (mark))) | |
(save-excursion | |
(indent-rigidly (region-beginning) | |
(region-end) | |
distance) | |
(push-mark mark t t) | |
(setq deactivate-mark nil))) | |
(indent-rigidly (line-beginning-position) | |
(line-end-position) | |
distance))) | |
(defun shift-right (count) | |
(interactive "p") | |
(shift-text count)) | |
(defun shift-left (count) | |
(interactive "p") | |
(shift-text (- count))) | |
(global-set-key (kbd "C-x >") (lambda () (interactive) (shift-right 4))) | |
(global-set-key (kbd "C-x <") (lambda () (interactive) (shift-left 4))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment