Emacs: Easy Ctrl+x for Dvorak Layout

By Xah Lee. Date: . Last updated: .

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 F8 Do Ctrl+X

a good solution is to make F8 key do Ctrl+x

(global-set-key (kbd "<f8>") ctl-x-map)

Make Menu Key Do Ctrl+X

a good solution is to make ▤ Menu key do Ctrl+x

;; make the syntax "<apps>" "<menu>" same
;; on linux, the syntax for Menu key is <menu>, on Windows its <apps>
(define-key key-translation-map (kbd "<apps>") (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)

Swap 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)

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.