I'd like to be able to toggle
M-x font-lock-mode with a custom key binding like C-c l for example (or any minor mode for that matter).
Can this be done relatively easily?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
Add the following to your init file:
(global-set-key (kbd "C-c l") 'font-lock-mode)
You can follow the same pattern for any minor mode, because all minor modes are commands (meaning they can be bound to key sequences).
Moreover, anything you can invoke via
M-x is a command and can be bound to a key sequence (and using the key binding is equivalent to calling it via
n.b. Your choice of
C-c l is a good one, as
C-c followed by an upper- or lower-case letter is always a key sequence reserved for use by end-users, so it should never conflict with any other keymap.