I use vim as my editor and markdown to write the articles for my site. I think that the articles are easier to navigate when they have a table of contents.
Adding a table of contents was easy. Many plugins accomplish this. But I couldn't find a plugin that also added the anchors. And adding the anchors was a very tedious process. So I modified the vim-markdown-toc plugin to add the anchors.
If you are looking to do the same, I wrote a short post on how to do it with my modified version of the plugin. You can read about it here:
I hope you find it useful.
Top comments (2)
Nice. I used to use that plugin.
The beauty of vim, for me, is its adherence to the Unix Philosophy, which allows me to call external programs from within vim to accomplish something.
In this use-case, I can use doctoc CLI in any number of ways:
:! doctoc %
:TocBBcommands and custom function that call the respective
doctocflags (which can subsequently be automatically called on
BufWritePreevent on markdown filetypes)
:make md-tocmake target that calls
Another demonstration of vim's composability is this blog article posted a few days ago
Yea, you are right, I like that about vim. Another example of that composition I use every now and then is editing a file in binary form:
And then back: