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 Manager, dired]
ibuffer[see Emacs: List/Switch Buffers]
list-bookmark[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.
Emacs Keybinding How-To Topic
- Emacs: How to Define Keys
- Emacs: Change Major Mode Keys
- Emacs: Change Minor Mode Keys
- Emacs: Fix Minor Mode Key Priority
- Emacs: Define Key Sequence
- Emacs: How to Bind Super Hyper Keys
- Emacs: How to Define Menu Key
- Emacs: Remapping Keys Using key-translation-map
- Emacs: Bind Number Pad Keys
- Emacs: How to Set Mouse Buttons