Created
January 24, 2014 18:01
-
-
Save bonkydog/8602622 to your computer and use it in GitHub Desktop.
Make Emacs Alt-/ behave more like RubyMine: toggle comment on region or toggle comment on line (and then move down to next 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 toggle-comment-for-line-or-region (arg) | |
| "Make Emacs Alt-/ behave more like RubyMine: toggle comment on region or | |
| toggle comment on line (and then move down to next line)." | |
| (interactive "*P") | |
| (let ((initial-mark-state (and mark-active transient-mark-mode))) | |
| (unless initial-mark-state | |
| (mark-line)) | |
| (comment-or-uncomment-region (region-beginning) (region-end) arg) | |
| (unless initial-mark-state | |
| (next-line)) | |
| (font-lock-fontify-buffer))) | |
| (global-set-key (kbd "M-/") 'toggle-comment-for-line-or-region) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment