diff options
| author | Ravi R Kiran <aine.marina@gmail.com> | 2013-12-29 05:56:09 (GMT) |
|---|---|---|
| committer | Ravikiran Rajagopal <aine.marina@gmail.com> | 2013-12-29 05:56:09 (GMT) |
| commit | 78545d188db777279206b70bc68e69387177f5a8 (patch) | |
| tree | ce1b635f1b7cbf4d449ddc1585ca0739e979406b /ravi-init-navigation.el | |
| parent | b2ee30d498b33771b20067e95b943a218c5a8101 (diff) | |
| download | dotemacs-78545d188db777279206b70bc68e69387177f5a8.zip dotemacs-78545d188db777279206b70bc68e69387177f5a8.tar.gz dotemacs-78545d188db777279206b70bc68e69387177f5a8.tar.bz2 | |
Duplicate lines easily
Diffstat (limited to 'ravi-init-navigation.el')
| -rw-r--r-- | ravi-init-navigation.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index e52a85b..bef87ca 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -109,6 +109,33 @@ ) ) +;; From Kyle Sherman's comment at +;; http://emacs-fu.blogspot.com/2010/01/duplicating-lines-and-commenting-them.html +;; \todo Make this work someday with regions too. +(defun ravi/kyle-sherman-duplicate-line (&optional comment line) + "Duplicate the line containing the point. +\nIf COMMENT is non-nil, also comment out the original line. + If LINE is non-nil, duplicate that line instead." + (interactive "P") + (let ((col (current-column))) + (save-excursion + (when line + (goto-line line)) + (let ((line (buffer-substring (point-at-bol) (point-at-eol)))) + (when comment + (comment-region (point-at-bol) (point-at-eol))) + (goto-char (point-at-eol)) + (if (eobp) + (newline) + (forward-line 1)) + (open-line 1) + (insert line))) + (forward-line 1) + (move-to-column col))) + +;; C-: duplicates line, C-u C-: comments first line +(bind-key "C-:" 'ravi/kyle-sherman-duplicate-line) + ;; grep and friends (use-package wgrep |
