This question already has an answer here:

Sadly, my Emacs is too old (and not mine to upgrade) and so I can't run markdown-mode. I'd like to set a buffer to fill mode when I open an .md file.

Is there a simple way to do this? The whole add a hook approach seems like overkill, but maybe it's the only way?

marked as duplicate by Tyler, DoMiNeLa10 Jan 8 at 18:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The variable auto-mode-alist controls setting the mode for a file based on the file extension. You can add an element for .md files with this:

(add-to-list 'auto-mode-alist
         '("\\.md\\'" . auto-fill-mode))

Note that auto-fill-mode is a minor mode, so the major mode in this case will be the default fundamental-mode. Depending on what you want to achieve, it might be better to set markdown files to use text mode, and add a hook for text-mode to apply auto-fill-mode in text modes.

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