Suggest to manage your vim plugins via vim-plug or Vundle, so you can install it simply three steps:
vim-plug
add the following line to your vimrc file
Plug 'mzlogin/vim-markdown-toc'
:so $MYVIMRC
:PlugInstall
Vundle
add the following line to your vimrc file
Plugin 'mzlogin/vim-markdown-toc'
:so $MYVIMRC
:PluginInstall
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.
You can view here to know differences between GFM and Redcarpet style toc links.
Update existing table of contents
Generally you don't need to do this manually, existing table of contents will auto update on save by default.
The :UpdateToc command, which is designed to update toc manually, can only work when g:vmt_auto_update_on_save turned off, and keep insert fence.
Remove table of contents
:RemoveToc command will do this for you, just remember keep insert fence option by default.
Options
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:
letg:vmt_auto_update_on_save=0
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 and :UpdateToc command, 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:
letg:vmt_dont_insert_fence=1
But then you will lose the convenience of auto update tables of contents on save and :UpdateToc command. When you want to update toc, you need to remove existing toc manually and rerun :GenTocXXX commands.
g:vmt_fence_text
default: vim-markdown-toc
Inner text of the fence marker for the table of contents, see g:vmt_dont_insert_fence.
g:vmt_fence_closing_text
default: g:vmt_fence_text
Inner text of the closing fence marker. E.g., you could let g:vmt_fence_text = 'TOC' and let g:vmt_fence_closing_text = '/TOC' to get
<!-- TOC -->
[TOC]
<!-- /TOC -->
g:vmt_fence_hidden_markdown_style
default: ''
By default, vim-markdown-toc will add the markdown style into the fence of the text for the table of contents. You can avoid this and set a default markdown style with g:vmt_fence_hidden_markdown_style that is applied if a fence is found containing the g:vmt_fence_text without any markdown style. Obviously, g:vmt_fence_hidden_markdown_style has to be supported, i.e. currently one of ['GFM', 'Redcarpet', 'GitLab', 'Marked'].
g:vmt_cycle_list_item_markers
default: 0
By default, * is used to denote every level of a list:
请发表评论