Emacs: Xah Fly Keys, Add Keys to Switch Mode

By Xah Lee. Date: . Last updated: .

Optimal Key Choice to Activate Command / Insert Mode

Note, the key for activating command mode or insert mode should be a single key press, not chord, because you'll need to call this command few times per minute.

If you have a batman keyboard or Foot Pedal, adding keys to activate command mode is very useful.

Add a Global Key to Activate Command Mode

Here's a example of how to add a command mode activation key.

;; make the f4 key switch to command mode
(global-set-key (kbd "<f4>") 'xah-fly-command-mode-activate)

see also Emacs: Xah Fly Keys Escape Key

Add a Global Key to Activate Insert Mode

Normally, you switch to command mode, then press a key to activate insert mode. But you can add a dedicated key to activate insert mode if you have extra thumb keys on your keyboard. 〔see Ergonomic Keyboard Reviews

;; make End key to activate insertion mode
(global-set-key (kbd "<end>") 'xah-fly-insert-mode-activate)

Add Global Key to Toggle Command/Insert

;; make F4 toggle command/insert mode
(global-set-key (kbd "<f4>") 'xah-fly-mode-toggle)

Add Key to Insert Mode to Activate Command Mode

If you don't want to add a global key such as F4 to activate command mode, because they are too far, and you don't have a batman keyboard with extra thumb keys, but you want to use some easy to reach key such as backslash to activate command mode while you are in insert mode, here's how.

This is useful when you want a single key to switch back to command mode while in insert mode.

(define-key xah-fly-insert-map (kbd "\\") 'xah-fly-command-mode-activate)

note: if you set \ to do something while in insert mode, you won't be able to insert a backslash by the key \. To insert a backslash, press Ctrl+q first.

emacs, Xah Fly Keys, customization