I'm configuring emacs, and have run into a roadblock trying to configure C-c to be copy:
;; Copy, cut
(global-unset-key (kbd "C-c"))
(global-unset-key (kbd "C-x"))
(global-set-key (kbd "C-c") 'kill-ring-save)
(global-set-key (kbd "C-x") 'kill-region)
Cutting works as expected, but when I have a region selected and press C-c, nothing happens, it waits for a key chord, and then does not copy at all. I have unbound control+c from the terminal, checked it can receive it as a signal properly on the terminal level, and removed all other possible keybindings messing with C-c. I don't want C-c to be a chord command and am perfectly happy to be rid of that. If possible, I'd also like to have the behaviour of copying the current line if no region is selected as well, but I am willing to live without that if I can get working copy at all! I have even added:
;; Copying stuff
(setq select-enable-clipboard t) ; Use system clipboard
(setq select-enable-primary t) ; Use primary selection (middle-click paste)
(when (not (display-graphic-p))
;; Fix terminal C-c handling
(define-key input-decode-map "\e[27;5;99~" [C-c]))
To absolutely ensure C-c should work, but it waits for a chord. How can I fix this?
Use cua-mode
instead.
That is Emacs' built-in support for using C-c
, C-x
, and C-v
as copy/cut/paste (and C-z
for undo). For details, refer to the manual:
https://gnu.org/software/emacs/manual/html_node/emacs/CUA-Bindings.html
That does what you want without preventing you from accessing the prefix bindings, which is better than what you were attempting to do, as C-c
and C-x
are two of the most heavily utilised prefix keys in all of Emacs.