Emacs: How to Turn Major/Minor Mode on/off?

By Xah Lee. Date: . Last updated: .

This page is a tutorial on how to turn a emacs mode on, off, or toggle.

Turn On/Switch Major Mode

Each buffer/file is associated with one major mode.

A “major mode” is a set of features, designed for specific task. Typically, for working with programing languages, or other things such as viewing directory (dired) , viewing image files, Web Browser, etc.

To turn on a major mode, just call the associated command. Typically, if a mode is named “xyz-mode”, the command to turn it on is named “xyz” or “xyz-mode”.

To turn “off” a major mode, just switch to another major mode. There's always one major mode on.

The most basic major mode is fundamental-mode. So, in a sense if you want to “turn off” all major modes, just call fundamental-mode.

Minor Modes

Emacs: What's Minor Mode?

Writing a Toggle Mode Command

You can write a toggle command that toggles a set of minor modes or other things such as switching between 2 fonts. See: Emacs Lisp: How to Write a Toggle/Cycle Command

Like it? Buy Xah Emacs Tutorial. Thanks.