I have 3 use cases for the table or contents or as it's also known TOC:
when I print a PDF from neovim using the markdown-preview plugin the links on that PDF are clickable thanks to this TOC
I push my markdown files to github, and sometimes I need to view my notes on my phone, so I use the github mobile app for that, by default it shows you raw markdown files, but you have the option to view as HTML, in this HTML view the TOC is clickable, so you can navigate to the different headings on your phones
I also manage my blogpost in markdown, so it's useful to have a TOC at the top of each file
In this video I will show you how to install the plugin we will use, which is markdown-toc in neovim, you don't need to do this only on neovim, you could do it on your local computer as well, I use the lazyvim distro, which has what is known as LazyExtra features, one of these LazyExtras is Markdown, that installs the plugin
If you don't use the lazyvim distro, you can install the plugin via Mason, I'll show you how in the video
Once you have the plugin installed, I'll show you the keymap that I configured to create the table of contents, I press leader+m+t+t to add it in English, or leader+m+t+s to add it in Spanish, you don't need to configure both keymaps, just the one that you need. If the TOC already exists and you press the keymap, its just going to update it. The great thing is that you don't have to quit neovim, just press a keymap the the TOC is updated
If your markdown file has frontmatter at the top, no worries, the keymap will still work without any issues
If you find this video helpful and want to support me
https://ko-fi.com/linkarzu
Follow me on twitter
https://x.com/link_arzu
My dotfiles
https://github.com/linkarzu/dotfiles-...
0:00 - TOC inside neovim
0:58 - TOC in pdf files
1:55 - TOC in github mobile app
3:00 - TOC in blogpost
3:50 - generate TOC with keymap
4:57 - install markdown-toc
6:48 - configure keymap
7:28 - how to update the TOC
7:59 - what if the file has frontmatter
8:31 - my dotfiles