Reputation: 9497
According to issue #4883 and PR #15320 you can create vscode:/
links in your HTML:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<h1>Test</h1>
<a href="vscode://path/to/my/file.md">open file.md in vscode</a>
</body>
</html>
This should have the same effect than typing following in the console:
code -g -r /path/to/my/file.md
But what I get is different:
After click:
And after clicking on "Open Visual Studio Code", then the application is opened (or put in the foreground) but the file is not opened.
What did I miss?
I have tried <a href="vscode:///path/to/my/file.md">
but the result is the same.
Upvotes: 5
Views: 5411
Reputation: 9497
I found the solution in this answer: you need a file/
prefix before the path of your file:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<h1>Test</h1>
<a href="vscode://file/path/to/my/file.md">open file.md in vscode</a>
</body>
</html>
Upvotes: 6