Created
June 13, 2012 09:01
-
-
Save rejeep/2922929 to your computer and use it in GitHub Desktop.
Comment and duplicate line
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 comment-and-duplicate-line () | |
"Copy current line to line below and comment current line." | |
(interactive) | |
(let* ((beg (line-beginning-position)) | |
(end (line-end-position)) | |
(line (buffer-substring-no-properties beg end)) | |
(column (current-column))) | |
(comment-region beg end) | |
(goto-char (line-end-position)) | |
(newline) | |
(insert line) | |
(move-to-column column))) | |
(global-set-key (kbd "C-c C-d") 'comment-and-duplicate-line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment