简体   繁体   中英

How to open a file in vscode from browser?

I want my webapp to be able to open a given file in VS code. For example, when I click a button on my webapp, a file say, C:\\Users\\...\\myProject\\index.html is opened, if myProject is already opened it should navigate to index.html

I know its a peculiar use case but I want to know if its possible in vscode.

Its also completely fine if it requires using browser or vscode extension.

vscode://file/{full path to project}/

感谢 fbg13 提供此链接

It is possible if you are using Firefox:

  • Open the about:config page.
  • Set the view_source.editor.external to true .
  • Set the view_source.editor.path to the VSCode's executable absolute path.

你可以安装vscode-handler来打开这样的文件

vscode://open?url=file://%file&line=%line

It is possible if you add this link:

vscode://file/{fullpath}:{numrow}

For example in Symfony to use the link that appears in the debug bar of the controler used you can do it like this:

edit the file "...\config\packages\framework.yaml"

add this code:

ide: 'vscode://file/%%f:%%l'

for more details see this page: Symfony Framework Configuration Reference - ide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM