2

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?

1 Answer 1

4

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 M-x).

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.