Emacs: Define Key Sequence
In emacs, you can define key sequences.
Suppose you want:
- 【F9 F6】for
- 【F9 F7】for
- 【F9 f8】 for
(progn ;; define a prefix keymap (define-prefix-command 'my-xyz-map) (define-key my-xyz-map (kbd "<f6>") 'visual-line-mode) (define-key my-xyz-map (kbd "<f7>") 'linum-mode) (define-key my-xyz-map (kbd "<f8>") 'whitespace-mode) ) (global-set-key (kbd "<f9>") my-xyz-map) ;; now, 【F9 F6】 will call visual-line-mode
Press the lead key, then you can press 【Ctrl+h】 to see all available key/commands that follows.
Why is Key Sequence Useful
- Key sequence shortcuts multiplies your available function keys. You trade one single easy key spot for some 50 possible 2 key strokes.
- These commands are take-a-break commands. That is, they are often used when there is a discontinuity in your editing activity.
- Yes, function keys are further away and need reach. That's why they are used for discontinuity commands here. Also, when the amount of typing comes close to a data-entry clerk, you want to move your hand about, to reduce overuse of the same hand muscle in the same position.
You can add other commands you use, for example:
dired〔➤see Emacs: File Management (dired tutorial)〕
ibuffer〔➤see Emacs: List/Switch Buffers〕
bookmark-bmenu-list〔➤see Emacs: Bookmark Tutorial〕
recentf-open-files〔➤see Emacs: Open Recently Opened File〕
- Any command to activate a major mode that you use often.
- Any minor mode you want to toggle often.
Like it? Buy Xah Emacs Tutorial. ♥ Thanks.
or, buy something from Best Keyboard for Emacs