Skip to content

Instantly share code, notes, and snippets.

@bonkydog
Created January 24, 2014 18:01
Show Gist options
  • Select an option

  • Save bonkydog/8602622 to your computer and use it in GitHub Desktop.

Select an option

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).
(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