Emacs: How to Make Ctrl+x Easier to Type on Dvorak Keyboard
if you use Dvorak Keyboard Layout with emacs, you may want to change the 【Ctrl+x】 key to something else, such as 【Ctrl+t】 where the t is right under your right hand's middle finger.
addendum: i recommend not to use any of C-x at all. Define them as key sequences. See: The Roadmap to Completely Replace Emacs's Key System, Part 2. For a packaged lunchbox, use ErgoEmacs Keybinding or Xah Fly Keys.
Nicolas Goaziou suggested the following. It works well.
;; Swap “C-t” and “C-x”, so it's easier to type on Dvorak layout (keyboard-translate ?\C-t ?\C-x) (keyboard-translate ?\C-x ?\C-t)
Another good solution is to make F6 or ▤ Menu key do 【Ctrl+x】.
;; on linux, the syntax for Menu key is <menu>, on Windows its <apps> (define-key key-translation-map (kbd "<apps>") (kbd "<menu>")) ;; make F6 type Menu key (define-key key-translation-map (kbd "<f6>") (kbd "<menu>")) ;; set Menu/App key to do emacs's C-h (global-set-key (kbd "<menu> h") help-map) ;; set Menu/App key to do emacs's C-x (global-set-key (kbd "<menu> x") ctl-x-map) ;; set 【Menu Enter】 to do emacs's M-x (global-set-key (kbd "<menu> <return>") 'execute-extended-command)
There are 2 common solutions offered:
;; Make “C-t” act like “C-x”, so it's easier to type on Dvorak layout (keyboard-translate ?\C-t ?\C-x)
;; Make “C-t” act like “C-x”, so it's easier to type on Dvorak layout (global-set-key (kbd "C-t") ctl-x-map)
Both solutions are not perfect.
keyboard-translate means, ALL your 【Ctrl+t】 keys becomes 【Ctrl+x】. This means you lost any keybinding that has a 【Ctrl+t】 in it.
For example, in
outline-mode, 【Ctrl+c Ctrl+t】 runs
hide-body. But now, when you type that, you get 【Ctrl+c Ctrl+x】 instead.
Solution with “ctl-x-map” has its own problems.
I often do 【Ctrl+x r l】 (
list-bookmark) to get my bookmark list.
But if you are in dired, that no longer works. 【Ctrl+t r】 invokes
cua-mode on, and when you have a text selection, you need to press 【Ctrl+x】 twice quickly to invoke the traditional 【Ctrl+x】 role. So, that means you press 【Ctrl+t】 twice quickly.
One example i'll need to do this many times per day is 【Ctrl+t r t】 (
string-rectangle) and 【Ctrl+t r k】 for
kill-rectangle, where you do need a selection on first.
But now 【Ctrl+t Ctrl+t r t】 no longer works. It invokes
transpose-lines before you finish your key sequence.
Between these 2 solution, i'm not sure in practice which is better. I've been using the
keyboard-translate for ~4 years, and didn't really notice any problem. Probably because if there's some binding involving 【Ctrl+t】 in the middle, it's probably a command rarely used.
With the “ctl-x-map” solution, within a day i noticed the problem with it in dired and calling rectangle commands. So, i presume
keyboard-translate is a more practical solution.
With the above info, perhaps a even better solution is just to make some function key to do 【Ctrl+x】.
So, i'll try
(global-set-key (kbd "<f8>") ctl-x-map)
This solution does not have any of the problems mentioned above, it also does away the
cua-mode's problem of needing to type 【Ctrl+x】 twice quickly. It is probably a good thing for reducing too many complex key presses that starts with 【Ctrl+x】.
PS: All these extra personalized fixes create a lot complications. If emacs developers made the decision to update emacs UI to a modern one, with ZXCV keys for undo/cut/copy/paste, then complications like the above will be much reduced, as compared to individualistic customization that tried to achieves the same thing. This is because when emacs has something out of the box, the implementation is more thoroughly examed at some lower level, i.e. creating much more robustness than individual hacks. The
cua-mode itself is a complex hack layed on top of emacs.
If you have a question, put $5 at patreon and message me.