-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshift-region.el
More file actions
27 lines (22 loc) · 817 Bytes
/
Copy pathshift-region.el
File metadata and controls
27 lines (22 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;; Shift the selected region right if distance is postive, left if
;; negative
(defun shift-region (distance)
(let ((mark (mark)))
(save-excursion
(indent-rigidly (region-beginning) (region-end) distance)
(push-mark mark t t)
;; Tell the command loop not to deactivate the mark
;; for transient mark mode
(setq deactivate-mark nil))))
(defun shift-right ()
(interactive)
(shift-region 1))
(defun shift-left ()
(interactive)
(shift-region -1))
;; Bind (shift-right) and (shift-left) function to your favorite keys. I use
;; the following so that Ctrl-Shift-Right Arrow moves selected text one
;; column to the right, Ctrl-Shift-Left Arrow moves selected text one
;; column to the left:
(global-set-key [M-S-right] 'shift-right)
(global-set-key [M-S-left] 'shift-left)