0

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?

1
  • You have overridden global bindings, but I would guess you have some non-global bindings there, since many major modes use C-c for something. Try C-c C-h to see what commands start with C-c. Commented Apr 29 at 22:42

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.