sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

vim-markdown-toc : A plugin to generate table of contents for Markdown files.

 script karma  Rating 9/3, Downloaded by 168    Comments, bugs, improvements  Vim wiki

created by
Ma Zhuang
script type

In GitHub: https://github.com/mzlogin/vim-markdown-toc

## Screenshots


## Features

* Generate table of contents for Markdown files.

  Supported Markdown parsers:

  - [x] GFM (GitHub Flavored Markdown)
  - [x] Redcarpet

* Update existing table of contents.

* Auto update existing table of contents on save.

## Usage

### Generate table of contents

Move the cursor to the line you want to append table of contents, then type a command below suit you. The command will generate **headings after the cursor** into table of contents.

1. `:GenTocGFM`

    Generate table of contents in [GFM][2] link style.

    This command is suitable for Markdown files in GitHub repositories, like `README.md`, and Markdown files for GitBook.

2. `:GenTocRedcarpet`

    Generate table of contents in [Redcarpet][3] link style.

    This command is suitable for Jekyll or anywhere else use Redcarpet as its Markdown parser.

You can view [here][1] to know differences between *GFM* and *Redcarpet* style toc links.

### Update existing table of contents manually

Just use `:UpdateToc` command.

## Options

1. `g:vmt_auto_update_on_save`

   default: 1

   This plugin will update existing table of contents on save automatic.

   You can close this feature by add the following line to your vimrc file:

   let g:vmt_auto_update_on_save = 0

2. `g:vmt_dont_insert_fence`

   default: 0

   By default, the `:GenTocXXX` commands will add `<!-- vim-markdown-toc -->` fence to the table of contents, it is designed for feature of auto update table of contents on save, it won't effect what your Markdown file looks like after parse.
   If you don't like this, you can remove the fence by add the following line to your vimrc file:
   let g:vmt_dont_insert_fence = 1
   But then you will lose the convenience of auto update tables of contens on save.
install details

Suggest to manage your vim plugins via [Vundle][4] so you can install it simply three steps:

1. add the following line to your vimrc file

    Plugin 'mzlogin/vim-markdown-toc'

2. `:so $MYVIMRC`

3. `:PluginInstall`

Installation with [vim-plug][8] is likeness.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-markdown-toc-1.2.1.tar.gz v1.2.1 2016-11-23 7.0 Ma Zhuang Compatible with old regexp engine.
vim-markdown-toc-1.2.tar.gz v1.2 2016-11-07 7.0 Ma Zhuang Compatibility enhancement
vim-markdown-toc-1.0.tar.gz v1.0 2016-10-19 7.0 Ma Zhuang Add features: update existing toc, auto update toc on save.
vim-markdown-toc-0.1.tar.gz v0.1 2016-10-10 7.0 Ma Zhuang Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo