bruchieOP · 2022-10-03 06:58
I was reading this [article](https://esrh.me/posts/2022-04-07-dvorak-and-editing.html) and one snippet was :
> Undoubtedly the worst binding I’ve had to deal with is C-x on emacs. I took the suggestion from the emacswiki and swapped C-u and C-x. I barely use C-u anyway, and this places C-x right under the pointer in the home row, which is very comfortable. Common sequences like C-x C-s and C-x C-e become optimal homerow rolls.
I was wondering how to do that natively in emacs without using karabiner/xmodmap or other OS dependent solution?
lebensterben · 2022-10-03 07:31
just remap Ctrl to Command and you will be able to use thumb and index finger of your left hand to press any key combos.
bruchieOP · 2022-10-03 08:10
thanks, but that's not what I am asking (:
guitmz · 2022-10-03 08:37
(keyboard-translate ?\C-x ?\C-u)
Or
(global-set-key (kbd "C-u") 'ctl-x-map)
Failware_ · 2022-10-03 09:05
The following should do (mostly) what you want.
```
(define-key global-map (kbd "C-u") ctl-x-map)
(define-key global-map (kbd "C-x") #'universal-argument)
;; or the following to override minor-mode bindings for C-x (I'm not sure whether this is actually a good idea)
(define-key override-global-map (kbd "C-x") #'universal-argument)
```
I recommend reading https://www.masteringemacs.org/article/mastering-key-bindings-emacs#keymap-lookup-order
OutsideNo1877 · 2022-10-03 12:16
Thats actually a good idea x is in a really awkward position for how often its used
thetemp_ · 2022-10-03 13:27
My preferred method would be this:
(edited because I forgot the arguments need to be characters, not key sequences)
(keyboard-translate ?\C-u ?\C-x)
(keyboard-translate ?\C-x ?\C-u)
This swaps the keys anywhere they appear in a key sequence. So "C-x C-x" (for `exchange-point-and-mark`), becomes "C-u C-u", a double-press of the same key, just like the original keybinding.
And "C-x C-u" (for `upcase-region`) becomes "C-u C-x". (I personally never use that one since I have M-u bound to `upcase-dwim`, which handles the same task).
Another popular key to swap with "C-x" on Dvorak is "C-t". I actually like that one more than "C-u", because it's under the right hand. But "t" as a base key is used for the transposition bindings. So `transpose-chars` would be moved from "C-t" to "C-x". And "C-x C-t" (for `transpose-lines`) would be accessible via "C-t C-x". For consistency, you might also want to swap "M-t" (`transpose-words`) with "M-x" (`execute-extended-command`) and "C-M-t" (`transpose-sexps`) with "C-M-x" (`eval-defun`). However, since Emacs doesn't view "M-t/M-x" and "C-M-t/C-M-x" as regular characters, you can't use the `keyboard-translate` function to swap them. Instead, you would want to use `define-key` or `global-set-key` to swap the commands bound to those keys.
bruchieOP · 2022-10-04 02:59
Thanks for the detailed answer, very helpful..
Have a good day!
copperbranch · 2022-10-04 15:35
It's interesting to see how one's "solution to the Ctrl key issue" will make some things more comfortable than others.
In my case, because I use right alt as ctrl, C-x is actually much more comfortable than C-u.
OutsideNo1877 · 2022-10-22 22:26
For whatever reason when i hit C-x it stays as C-x and switches to C-u when i press another key C-u doesn’t do this
thetemp_ · 2022-10-23 02:27
I edited my comment because the original code gave an error since `keyboard-translate` doesn't accept output from `kbd`. The new version should work. Just be sure to evaluate the lines in the order they appear now, if you're using "C-x C-e".
Are you sure you were using the `keyboard-translate` version when this happened?
OutsideNo1877 · 2022-10-23 02:53
Yes i was it still does it now if i change it back but after running the new one it works fine