VS Code Markdown - is there a clever way to make links intellisense?

2.2k Views Asked by At

I've started using VisualStudio Code and Markdown as a note-taking tool - something akin to Zettelkasten. As part of this note-taking system, notes should always be linking to other notes/files.

As recovering developer I start to write: [Decision Making Techniques](.\ ) - when I type .\ and then ctrl+space I expect a list of filenames. Instead, I get a list of words.

Is there a simple? (gasp elegant way?) to have IntelliSense recognize filenames as distinct kind of thing in Markdown mode?

4

There are 4 best solutions below

0
Mark On BEST ANSWER

And speaking of clever ways to make markdown links, vscode 1.76 is adding the ability to easily make a link to any header in the same file or another markdown file. See markdown header links: v1.76 Release Notes:

Need to link to a header in another Markdown document but don't remember or want to type out the full file path? Try using workspace header completions! To start, just type ## in a Markdown link to see a list of all Markdown headers from the current workspace

(my demo):

markdown header links suggestions

You can configure if/when workspace header completions show with the markdown.suggest.paths.includeWorkspaceHeaderCompletions setting. Valid setting values are:

  • onDoubleHash (the default) — Show workspace header completions only after you type ##.
  • onSingleOrDoubleHash — Show workspace header completions after you type # or ##.
  • never — Never show workspace header completions.

Keep in mind that finding all headers in the current workspace can be expensive, so there may be a slight delay the first time they are requested, especially for workspaces with lots of Markdown files.


In the Insiders Build v1.64 there is now path intellisense for markdown links.

Enable this setting: markdown.suggest.paths.enabled default is true

See Commit: Add basic markdown link completions

Only normal links for now. Will add reference links later. Should support the forms:

  • [](dir/file.md)
  • [](./dir/file.md)
  • [](/root-dir/file.md)
  • [](#header)
  • [](./dir/file.md#header)

See also https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_64.md#markdown-path-intellisense

2
Mark Levison On

Strangely, I'm now able to answer my own. The plugin Markdown All in One has this facility built in. I suspect that Path Autocomplete would have worked as well.

1
DirtyF On

Foam is a personal knowledge management and sharing system inspired by Roam Research, built on Visual Studio Code and GitHub.

2
Kiran On

Intellisense support can be controlled by Extensions, so as has been correctly pointed out, a few extensions add this capability to your workspace.

A more technical answer is also probably required and you can see an example commit that adds autocomplete support for markdown here.

In general, you will need to:

  1. populate a provider with completion items.
  2. get a handle to the vscode extension context.
  3. add your provider to the list of supported vscode completion providers.

Similar to foam, Dendron also builds in markdown link autocomplete and also adds in lots of features like publishing, flexible hierarchies, preview support etc.

For additional docs, see the vscode api.