4

The February 2017 (version 1.10) release notes for Visual Studio Code describes something they call "Fragment link navigation for Markdown." Here is the description:

"Links to Markdown files that include a fragment will now try to open the file at the corresponding header:

* [Section](#_header)
* [Another file](./other_file#_header)

# Header
...

This allows quickly navigating documentation directly within the VS Code editor."

I've searched for any more information on this topic but haven't found anything. Fragments in Markdown? I didn't know that was possible. Can someone point me to more information?

Steve Nay
  • 73
  • 1
  • 4
  • This may help you understand what's meant by "fragment": [How to link to part of the same document in Markdown?](http://stackoverflow.com/q/2822089/866026). Presumably, VS Code is using the method described there under-the-hood. – Waylan Mar 03 '17 at 16:40

2 Answers2

8

I implemented this feature. Sorry for the unclear documentation

In 1.9, we added support for ctrlclick on links in the markdown editor to open the corresponding document.

Ctrl clicking [this link destination](./other_file.md) will open `other_file.md` in the editor

1.10 added support for navigating to a specific header in the current markdown file

Ctrl clicking [this link destination](#header) will scroll to # Header

... 

# Header

You can also use this across files:

Ctrl clicking [this link destination](./other-file.md#header) will open `other-file.md` and scroll to `#header`

This allows navigating markdown based documentation entirely within the editor. Here's the feature in action:


If you run into any bugs or have any feature suggestions for VSCode markdown support, please let us know: https://github.com/Microsoft/vscode/issues/new

Matt Bierner
  • 58,117
  • 21
  • 175
  • 206
  • perhaps you should add that an ID is automatically assigned to each header which allows the hashs to work in links. Autogenerating IDs for headers, while common, is not a standard Markdown feature and not known by all Markdown users. Its not even mentioned in the Markdown Syntax rules. Seems to me the OP was confused about "fragments" for this reason. – Waylan Mar 03 '17 at 16:29
  • Thanks, Matt -- I understand it now. I'm a technical writer and I'm all too aware of Markdown's shortcomings for efficient writing, such as no support for variable substitution or transclusion. I was hoping that "fragments" was a reference to a feature like that. This is a nice addition, though. – Steve Nay Mar 03 '17 at 18:41
1

In addition to the above, vscode v1.45 will be adding support to open folders referenced in markdown links in the explorer bar. Akin to "Reveal In SideBar" but for folders.

https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_45.md#markdown-link-to-folders

Markdown link to folders

Editor links in markdown files and links in the markdown preview can now point to folders. Clicking on one of these links will reveal the target folder in VS Code's explorer.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • See also https://stackoverflow.com/a/70699884/836330 for an easy way to add links to markdown headers in the same or another files. – Mark Mar 01 '23 at 04:35