please add a new feature of updating existing toc #6

Closed
hitzhangjie opened this Issue Apr 18, 2016 · 7 comments

Projects

None yet

3 participants

@hitzhangjie

First of all, thanks for your good work, it's very convenient to generate toc now. If you add a new feature like updating existing toc when triggering some hotkeys, it would be more useful. Is it right?
I have no vim script programming experience, but I think this is a good idea for some document which contains a long table of contents. If you add a updating-toc feature, we don't have to delete existing toc again. And I think inserting toc before the document is finished is useful too, because it can help us navigate the document.
So I think add a updating-toc feature is very useful. Thanks!

@hitzhangjie

I have another question, 'toc' generated by your plugin, I cannot used it for navigate in documents, I used 'instant-markdown' for realtime preview. Do they the two plugins conflict with each other?

@mzlogin
Owner
mzlogin commented Apr 18, 2016 edited

@hitzhangjie For your second question, it seems 'instant-markdown' use CommonMark as its Markdown parser, CommonMark does not add anchor to headings automatic default, and TOC link relyon this feature. Maybe you can find some options in these plugins to turn on it.

Unfortunately, different Markdown parser generate different anchor link for headlings, my current work is for GFM and Redcarpet, under CommonMark is untested.

At company I'm using Windows, and 'instant-markdown' doesn't support Windows official, so I cannot test the situation you said now. If you find the realtime preview page's headings have anchor with them, could you provider a demo generated html file to me for analyze? Thanks.

@mzlogin
Owner
mzlogin commented Apr 18, 2016

@hitzhangjie Updating existing toc is a good idea, I'll work on it when I got some free time.

@sunaku
sunaku commented Oct 18, 2016 edited

:neckbeard: Here is how I do this from Vim's command mode:

:/<!-- vim-markdown-toc \w\+ -->/,/<!-- vim-markdown-toc -->/d|execute 'normal! k'|GenTocGFM

You can replace GenTocGFM with GenTocRedcarpet as the last word of the command line too.

@sunaku
sunaku commented Oct 18, 2016 edited

Oops, this plugin already provides a :UpdateToc command. 🎅 Shouldn't this issue be closed then? 📕

@mzlogin
Owner
mzlogin commented Oct 19, 2016 edited

@sunaku Yeah, I updated the code yesterday to add :UpdateToc command and a feature of auto update toc on save, but have not update the README doc yet. Sorry about that, I'll do it soon. Your command mode command above is very concisely, thanks.

@hitzhangjie You can use :UpdateToc command to update existing toc generated by this plugin now, and by default, the toc will auto update when save, you also can add let g:vmt_auto_update_on_save = 0 to your vimrc file to close this feature.

@mzlogin mzlogin closed this Oct 19, 2016
@sunaku
sunaku commented Oct 19, 2016

Awesome! Auto-update on save sounds great! 👍 Thanks @mzlogin. 🎅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment