I have an absolute path to a file (/path_to_file/file.file
) embedded in my code, which is open in the VSCode editor. I want to create a shortcut to quickly open this file by either just clicking on the path or highlighting the path and pressing a shortcut.
// my code blabla
file = "/path_to_file/file.file"
I have something like this in mind, only it does not work:
keybindings.json:
[
{
"key": "ctrl+y",
"command": "editor.action.openFileAtPath",
"when": "editorTextFocus"
}
]
The command editor.action.openFileAtPath
does not exist. Is there an alternative?
2
Answers
With the help of the extensions HTML Related Links and Command Variable
If the file paths have a particular pattern in the file you can use the setting
html-related-links.include
and the extension will createCtrl+Click
links.The pattern could be all strings that start with a
/
:You will need an extension to do this. Another option is the Find and Transform extension (which I wrote). The necessary code is very small. This keybinding will find the path around the cursor – in your case assuming it is surrounded by quotes.