Specific lines of code in VS Code can be linked to via an application URL as documented here: https://code.visualstudio.com/docs/editor/command-line#_opening-vs-code-with-urls
It would be nice to be able right-click on a line of code and get the URL in your clipboard. I can't seem to find how to do this, or if it is even possible to configure VS Code to enable this.
The use case I can think of is pasting the URL into a task manager so when it comes time to work on that line of code, you can easily jump right to it versus trying to remember the code file / LOC.
Is this possible?
you can use the following task to print the url to the terminal, you can copy it from there
{
"version": "2.0.0",
"tasks": [
{
"label": "file URL",
"type": "shell",
"command": "echo vscode://file${command:extension.commandvariable.file.filePosix}:${lineNumber}",
"problemMatcher": []
}
]
}
It uses the extension Command Variable to get the correct file separators on Windows (/
). It only removes the :
of the drive, because you don't want that in Cygwin and MSys.
You can try if this works in opening VSC with the file and line number
"command": "echo vscode://file${file}:${lineNumber}",