If cua-mode is enabled, redefining Ctrl-Enter does not works as expected and always runs cua-set-rectangle-mark function. In the code below you can see that I also defined Alt-Enter to my function, just for testing, and it runs fine. But I wish to left Alt-Enter to cua-set-rectangle-mark because I prefer to use Ctrl-Enter to call my function that creates a line below the current line. What is wrong?
(cua-mode t)
(defun vscode-insert-line-below()
(interactive)
(move-end-of-line 1)
(newline-and-indent))
(global-set-key (kbd "C-<return>") 'vscode-insert-line-below)
(global-set-key (kbd "M-<return>") 'vscode-insert-line-below)
This is probably what you want:
(You can use either
(kbd "<C-return>")
or(kbd "C-<return>")
, but I like to use the form thatC-h k
shows me.)When you are in
cua-mode
the local keymap iscua-global-keymap
, and its bindings override the same global bindings.I found that map by doing
C-h k C-RET
incua-mode
. It told me: