Emacs markdown-mode

markdown-mode is a major mode for editing Markdown-formatted text files in GNU Emacs. markdown-mode is free software, licensed under the GNU GPL.

Download

The latest version is markdown-mode 1.5, released on October 11, 2007:

markdown-mode is also available in the Debian emacs-goodies-el package (beginning with revision 27.0-1).

Installation

Make sure to place markdown-mode.el somewhere in the load-path and add the following lines to your .emacs file to associate markdown-mode with .text files:

(autoload 'markdown-mode "markdown-mode.el"
   "Major mode for editing Markdown files" t)
(setq auto-mode-alist
   (cons '("\\.text" . markdown-mode) auto-mode-alist))

There is no consensus on an official file extension so change .text to .mdwn, .md, .mdt, or whatever you call your markdown files.

Usage

Although no configuration is necessary there are a few things that can be customized (M-x customize-mode).

The commands listed below are grouped by prefixes based on their function. For example, commands dealing with headers begin with C-c C-t. You can obtain a list of keybindings by pressing C-c C-h in Emacs.

Anchors (C-c C-a)

C-c C-a l

Creates an inline link. If there is an active region, this text will be used as the anchor text (markdown-insert-link).

Commands (C-c C-c)

C-c C-c m

Run markdown on the current buffer and preview the output in another buffer (markdown).

C-c C-c p

Run markdown on the current buffer and preview the output in a browser (markdown-preview).

Images (C-c C-i)

C-c C-i i

Insert an image, using the current region (if any) as the alt text (markdown-insert-image).

Physical Styles (C-c C-p)

C-c C-p b

Make the active region bold or insert an empty bold word (markdown-insert-bold).

C-c C-p f

Format the active region as fixed-width text or insert an empty fixed-width fragment (markdown-insert-code).

C-c C-p i

Make the active region italic or insert an empty italic word (markdown-insert-italic).

Logical Styles (C-c C-s)

C-c C-s b

Start a blank blockquote section unless there is an active region, in which case it is turned into a blockquote region (markdown-insert-blockquote).

C-c C-s c

Format the active region as inline code or insert an empty inline code fragment (markdown-insert-code).

C-c C-s e

Emphasize the active region or insert an empty emphasized word (markdown-insert-italic).

C-c C-s s

Make the active region strong or insert an empty strong word (markdown-insert-bold).

Headers (C-c C-t)

C-c C-t 1

Insert a level 1 hash header (markdown-insert-header-1).

C-c C-t 2

Insert a level 2 hash header (markdown-insert-header-2).

C-c C-t 3

Insert a level 3 hash header (markdown-insert-header-3).

C-c C-t 4

Insert a level 4 hash header (markdown-insert-header-4).

C-c C-t 5

Insert a level 5 hash header (markdown-insert-header-5).

C-c C-t t

Insert a level 1 underline header (markdown-insert-title).

C-c C-t s

Insert a level 2 underline header (markdown-insert-section).

Other

C-c -

Insert a horizontal rule (markdown-insert-hr).

Extensions

Besides supporting the basic Markdown syntax, markdown-mode also includes syntax highlighting for [[Wiki Links]] and mathematical expressions written in LaTeX (only expressions denoted by $..$, $$..$$, or \[..\]). To enable these features, edit markdown-mode.el and change (defvar markdown-enable-itex nil) to(defvar markdown-enable-itex t).

Bugs

This mode has only been tested on Emacs 21.4 and 22.0. Please let me know if there are problems on other versions. If you find any bugs, such as syntax highlighting issues, please construct a test case and email me.

Last modified: March 31, 2008 23:13 EDT.