0

I have tried using CUA mode but that failed to set this keybinding. I have also tried adding:

(global-set-key (kbd "C-x") 'kill-region)

to my ~/.emacs file. Despite this presently the Apropos buffer (started by pressing Ctrl+h+a) says the following:

kill-region           <menu-bar> <edit> <cut>, <S-delete>, C-w..C-x
   Cannot open doc string file "DOC"

about the kill-region command. Any ideas how to get Ctrl-x as the keybinding for cut. Here is my ~/.emacs file.

8
  • Why not just use the shortcuts the emacs way? Dec 8 '16 at 7:17
  • I'm used to these shortcuts. See no reason spending months trying to get comfortable to this editor's shortcuts when I can more easily use Atom with these shortcuts. So either I can assign these shortcuts the way I want them or I'll use another editor.
    – Josh Pinto
    Dec 8 '16 at 7:20
  • Shortcuts in emacs could looks diffucult or unusial at first, but its more than just elaborate in long-time perspective of using emacs. And don't forget about anoter programs that use emacs-like style by default. Dec 8 '16 at 8:08
  • 4
    Judging by your other questions, it seems like this is what you want to do: gnu.org/software/emacs/manual/html_node/emacs/CUA-Bindings.html . If you want more info on why what you initially tried didn't work: this is because Emacs has a concept of prefix keys, C-x is one such key, you cannot override it with global-set-key, which is not to say it's impossible, it's just that I'd advise against doing that, unless you are absolutely sure of what you are doing (wrt ELisp and programming Emacs).
    – wvxvw
    Dec 8 '16 at 9:14
  • 2
    As @wvxvw suggested, it looks like you want to get the CUA bindings working, rather than muck around with binding keys individually. (Start with no init file with emacs -Q, hit M-x cua-mode to confirm it works, and then figure out what's interfering in your init file by recursively bisecting it.) In general, I'd suggest that you start training your fingers to use Emacs-style keybindings: it really won't take that long. Otherwise, you're fighting the editor, which largely defeats the purpose of using Emacs.
    – Dan
    Dec 8 '16 at 15:05
1

It is probably being shadowed by a higher precedence keymap. The global map has the lowest precedence. One solution is to bind it with higher precedence which is easy if you use bind-key* from use-package like this

(bind-key* (kbd "C-x") 'kill-region)

One source for what the precendence rules are is here.

0

Seems to be fixed probably by the (global-set-key (kbd "C-x") 'kill-region) line. It just didn't seem to be fixed. I ran C-x from a ~/.emacs buffer and it cut text fine. It just seemed based on the Edit menu Cut entry and the output of Ctrl+h+a.

Not the answer you're looking for? Browse other questions tagged or ask your own question.