Files
.emacs.d/modules/text-editing/siren-toggle-comments.el
Jim Myhrberg ed5432641a feat(keybindings): add cmd+shift+p and cmd+/ keybindings from VSCode
Makes cmd+shift+p open the command palette and cmd+/ toggle comments, as
they do in VSCode.

This should ease my recent usage of Cursor/VSCode alongside Emacs, as
certain keybindings I have in Emacs cannot be setup in VSCode to work in
all contexts. Hence I've had to get used to cmd+shift+p instead of C-x
C-m, as the later does not want to play ball when a terminal is active
in VSCode.
2025-06-28 17:14:37 +01:00

29 lines
886 B
EmacsLisp

;;; siren-toggle-comments.el --- jimeh's Emacs Siren: toggle-comments
;;; Commentary:
;; Allows to toggle comments for current line or selected region.
;;; Code:
(use-package newcomment
:straight (:type built-in)
:general
("s-/" 'comment-or-uncomment-region-or-line)
("C-c /" 'comment-or-uncomment-region-or-line)
("C-c C-/" 'comment-or-uncomment-region-or-line)
("C-c C-_" 'comment-or-uncomment-region-or-line)
:preface
(defun comment-or-uncomment-region-or-line (&optional beg end arg)
"Comments or uncomments the region or current line."
(interactive "P")
(if (region-active-p)
(comment-or-uncomment-region (region-beginning) (region-end) arg)
(comment-or-uncomment-region (line-beginning-position)
(line-end-position) arg))))
(provide 'siren-toggle-comments)
;;; siren-toggle-comments.el ends here