Libraries providing multiple MajorModes in a buffer. See also MinorMode.


library elisp files size last update url
web-mode 1386 kb 2018-12-14
polymode 19260 kb 2019-01-03
mmm-mode 17185 kb 2018-06-21
multi-web-mode 116 kb 2013-08-23
mumamo 1153090 kb 2010-04-25
multi-mode 123 kb 2009


Major mode for editing web templates: HTML files embedding parts (CSS / JavaScript) and blocks (server and client side). web-mode.el is autonomous and is compatible with many template engines : PHP, JSP, GSP (Grails), ASP / ASP.NET AJAX (Atlas), Django / Twig / Jinja(2) / ErlyDTL (Zotonic) / Selmer, ERB, FreeMarker, Velocity, Cheetah, Smarty, CTemplate / Mustache / Hapax / Handlebars / Meteor / Blaze /ember.js, Blade (laravel), Knockoutjs, Go Template (Revel), Razor/Play, Dust, Closure (soy), underscore.js, template-toolkit, Liquid (jekyll), angular.js, web2py, mako (pylons), reactjs (jsx), mojolicious.

Actively maintained by François-Xavier Bois.


Polymode is a framework for multiple major modes (MMM) inside a single Emacs buffer. It is fast and has a simple but flexible object oriented design. Creating new polymodes normally takes a few lines of code.

Polymode also provides configurable facilities for literate programming - exporters, weavers and tanglers.



Auto select major mode for HTML files when point is moving around. Check updates at github. Written by FabianGallina. (Yes, it is actively maintained)


MuMaMo (short for multiple major modes) needs Emacs 22 or later. It is distributed as part of nXhtml and can mix HTML+CSS+JavaScript, Java+HTML (JSP), PHP. It can also support NxmlMode (however this works best with Emacs 23).

You can search mumamo regions by major mode using Icicles.


Multi Mode is an implementation of the approach referred to in Emacs’ TODO. It probably only works in Emacs 21 and later.

- I have been using it with Emacs 23 with no issue. It also has 2009 in its copyright notice, so it seems like it is still being updated.

See also its uses in noweb.el and haskell-latex.el in the same directory.

Multi-mode is used by aspx-mode.el, which is a mode for editing ASPX files in emacs. aspx-mode handles HTML, browser Javascript blocks, CSS blocks, and C#, with proper highlighting and indenting, all in one buffer.


Two Mode Mode by DavidWelton. This one is used for one of the solutions on the PhpMode page. It seems to be very easy to use. Just specify the start and end regular expressions for the second mode.

See EmacsLispAndLaTeX for an example.

Does two-mode-mode run on Emacs 23? I have tested it and it doesn’t change between modes.

I got it to work by changing the following:

    - (if (string= to-mode mode-name)
    + (if (string= to-mode major-mode)

Seems to need the following in emacs 24 since make-local hook has been removed:

    - (make-local-hook 'post-command-hook)

Indirect buffers

This is a built-in feature in Emacs. Indirect buffers feature does not exactly give multiple major modes in the same logical buffer but it gives user two (or more) different buffers which have their textual content linked together. To clone a buffer use ‘C-x 4 c’ and then use different major modes in the clones. See the Emacs reference manual for more information about indirect buffers. See also IndirectBuffers.

Library narrow-indirect.el facilitates creating indirect buffers cloned and narrowed from other buffers. And yes, you can use different major modes in them, even fontifying them differently etc. See NarrowIndirect.


What a shame that there are multiple multiple mode modes. As soon as you need mode X that requires multiple mode M1, while already using another mode which uses multiple mode M2, you’re loading far more than you need to. Just because TIMTOWTDI (sorry for the perl-ism) doesn’t mean you must do it more than one way.