Created
March 25, 2012 22:32
-
-
Save JEG2/2200432 to your computer and use it in GitHub Desktop.
An attempt to duplicate one of my favorite TextMate commands in Emacs.
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 jeg2s-duplicate-line-or-region () | |
| "Duplicate the current region, or line, and leave it selected." | |
| (interactive) | |
| (unless (region-active-p) | |
| (unless (bolp) | |
| (beginning-of-line)) | |
| (set-mark-command nil) | |
| (next-line)) | |
| (kill-region (region-beginning) (region-end)) | |
| (yank) | |
| (yank) | |
| (exchange-point-and-mark)) | |
| (global-set-key (kbd "C-c d") 'jeg2s-duplicate-line-or-region) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment