Emacs: Easy Ctrl+x for Dvorak Layout
Best is Avoid Key Chord
if you use Dvorak Keyboard Layout with emacs, you may want to change the Ctrl+x key to something else.
addendum: i recommend not to use any of C-x at all. Define them as key sequences. See: The Roadmap to Completely Replace Emacs Key System, Part 2. For a packaged solution, use Xah Fly Keys.
Make F6 or Menu Key Do Ctrl+X
a good solution is to make F6 or ▤ Menu key do Ctrl+x.
(global-set-key (kbd "<f8>") ctl-x-map)
or
;; 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 key to do emacs's C-h (global-set-key (kbd "<menu> h") help-map) ;; set Menu 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)
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.
Make Ctrl+t do Ctrl+x
2009-08-06 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)
Using 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.
Globally set ctl-x-map to a key
There are 2 common solutions offered:
;; 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)
not perfect.
Solution with “ctl-x-map” has its own problems.
I often do Ctrl+x r l (list-bookmarks
) to get my bookmark list.
But if you are in dired, that no longer works. Ctrl+t r invokes image-dired-delete-tag
.
Also, with 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.