DEV Community

Discussion on: Generating a table of contents with anchors for markdown - Vim plugin

Collapse
 
pbnj profile image
Peter Benjamin (they/them) • Edited

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 %
  • :TocGH/:TocGL/:TocBB commands and custom function that call the respective doctoc flags (which can subsequently be automatically called on BufWritePre event on markdown filetypes)
  • :make md-toc make target that calls doctoc .
  • or finally as a pre-commit git hook

Another demonstration of vim's composability is this blog article posted a few days ago

Collapse
 
rderik profile image
rderik

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:

:%!xxd

And then back:

::%!xxd -r