]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
move current line up or down with M-p and M-n.
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 11 Nov 2014 12:28:12 +0000 (13:28 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 11 Nov 2014 12:28:12 +0000 (13:28 +0100)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
bba.org
org/emacs.org

diff --git a/bba.org b/bba.org
index 5fea789fc2bd34c9effbaf92c59652a5ff1bf0de..c178a223193998e8a6c7cbc6ccebeb95e938c5a3 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -1119,6 +1119,38 @@ safe files with #! in first line as user executable.
 
 #+END_SRC
 
+*** move lines
+    [2014-11-11 Tue 12:24]
+
+=M-p= and =M-n= to move current line up or down.
+
+#+BEGIN_SRC emacs-lisp
+  (defun bba/move-line (n)
+    "Move the current line up or down by N lines."
+    (interactive "p")
+    (let* ((column (current-column))
+           (start (progn (beginning-of-line) (point)))
+           (end (progn (end-of-line) (forward-char) (point)))
+           (line-text (delete-and-extract-region start end)))
+      (forward-line n)
+      (insert line-text)
+      (forward-line -1)
+      (forward-char column)))
+
+  (defun bba/move-line-up (n)
+    "Move the current line up by N lines."
+    (interactive "p")
+    (bba/move-line (if (null n) -1 (- n))))
+
+  (defun bba/move-line-down (n)
+    "Move the current line down by N lines."
+    (interactive "p")
+    (bba/move-line (if (null n) 1 n)))
+
+  (define-key global-map (kbd "M-p") 'bba/move-line-up)
+  (global-set-key (kbd "M-n") 'bba/move-line-down)
+
+#+END_SRC
 *** key bindings
 #+BEGIN_SRC emacs-lisp
   (define-key global-map "\C-x\S-f" 'find-file-at-point)
@@ -1184,23 +1216,6 @@ function to convert groups of spaces to hard tabs.
   (define-key global-map (kbd "C-+") 'text-scale-increase)
   (define-key global-map (kbd "C--") 'text-scale-decrease)
 
-      ;; NUMBERIC KEYPAD. nice number pad conveniences as extra function keys
-
-      ;; (global-set-key (kbd "<kp-subtract>") 'ergoemacs-close-current-buffer)
-      ;; (global-set-key (kbd "<kp-divide>") 'ergoemacs-previous-user-buffer)
-      ;; (global-set-key (kbd "<kp-multiply>") 'ergoemacs-next-user-buffer)
-
-      ;; (global-set-key (kbd "<C-kp-divide>") 'ergoemacs-previous-emacs-buffer)
-      ;; (global-set-key (kbd "<C-kp-multiply>") 'ergoemacs-next-emacs-buffer)
-
-      ;; (global-set-key (kbd "<kp-decimal>") 'other-window)
-      ;; (global-set-key (kbd "<kp-0>") 'delete-window)
-      ;; (global-set-key (kbd "<kp-1>") 'delete-other-windows)
-      ;; (global-set-key (kbd "<kp-2>") 'split-window-vertically)
-      ;; (global-set-key (kbd "<kp-3>") 'xah-open-file-at-cursor)
-
-      ;; (global-set-key (kbd "<kp-9>") 'isearch-forward)
-
 #+END_SRC
 
 =isearch-forward-regexp= is much more useful than =isearch-forward= so
index a4791ac1feb2e17ea6540c33ffdfc315d8c76c83..843330a198a89ee49b05d26a69ee20a5ad39c01d 100644 (file)
 | F4                | next-buffer                                                                               |
 |-------------------+-------------------------------------------------------------------------------------------|
 | C-c t f           | toggle auto-fill-mode                                                                     |
+| C-c t i           | toggle impatient-mode                                                                     |
 | C-c t p           | toggle smartparens-mode                                                                   |
 | C-c t s           | toggle flyspell-mode                                                                      |
-| C-c t w           | toggle which-function-mode                                                                |
+| C-c t W           | toggle which-function-mode                                                                |
+| C-c t w           | toggle whitespace-mode                                                                    |
 |-------------------+-------------------------------------------------------------------------------------------|
+| C-x l b           | browse-url-at-point                                                                       |
 | C-x l c           | calculator                                                                                |
 | C-x l d           | ediff-buffers                                                                             |
 | C-x l i           | ielm                                                                                      |
 | C-x l S           | synonyms                                                                                  |
 | C-x l t           | git-timemachine                                                                           |
 |-------------------+-------------------------------------------------------------------------------------------|
+| M-p               | move current line up                                                                      |
+| M-n               | move current line down                                                                    |
+|-------------------+-------------------------------------------------------------------------------------------|
 | F11               | org-clock-goto                                                                            |
 | C-F11             | org-clock-in                                                                              |
-| C-c F12           | toogle Whitespace mode                                                                    |
 | F12               | org-agenda                                                                                |
 |-------------------+-------------------------------------------------------------------------------------------|
 | C-c a             | org-agenda                                                                                |