I want to be able to copy paste using C-c
and C-v
when I edit a file and in multi-term. After more than a few hours I gave up. I would be thankful if anyone could tell me what the recommended way for doing something like this is. Here are some of the things I tried:
Putting
(local-set-key (kbd "C-c") 'kill-ring-save) (local-set-key (kbd "C-x") 'kill-region) (local-set-key (kbd "C-v") 'yank)
in my find-file-hook
. This works for C-x
and C-v
but doesn't work for C-c
. (I think this is because of the C-c C-...
keybindings, but I don't know if there is some way to just overwrite those).
Defining a function that uses
(if (or (eq major-mode 'term-mode) (eq major-mode 'eshell-mode))
to detect whether we are in a terminal or a file and then deactivates cua-mode or activates it. I added this function to some hooks but it got buggy, because this function was either called not enough or too often. Also
(add-to-list 'term-bind-key-alist '("some binding" . some command))
works for C-v
and C-x
but not for C-c.
Note: I know that C-c
is normally terminal interrupt, but I put a stty intr ^J
in my .bashrc
.
- Using
eshell
instead of multi-term: The Problem with the eshell is, that it's autocompletion is not as good as the autocompletion of bash. Bash can e.g. autocomplete git chec to git checkout.
Note: I know that normal Emacs users use M-w
and and C-y to
copy-paste, but this would mess up my muscle memory when working with programs that use C-c
C-v
top copy-paste.
UPDATE: The following works:
(global-set-key (kbd "C-v") 'yank)
(global-set-key (kbd "C-x") 'kill-region)
(define-key input-decode-map (kbd "C-c") (kbd "M-w"))
(add-to-list 'term-bind-key-alist '("C-v" . term-paste))
Why is emacs so unnecessarily complicated?