How to copy a URL of code line in VSCode?

2.8k Views Asked by At

It happens often when I work in VSCode and I need to send a code line URL from a repo to a colleague.

There is no native support for this in VSCode. There is a capability that's enabled by Atlassian plugin if you are using Bitbucket. However, I've been looking for a more versatile option.

1

There are 1 best solutions below

1
exomen On BEST ANSWER

An answer I found using GitLens:

Option 1

  1. Install GitLens plugin in VSCode
  2. Open file from a cloned repo then Cmd+Shift+P > type GitLens: Copy
  3. Click on Settings cog and assign key binding (Cmd+C+P is free)
  4. Select a line from code in a cloned repo and use your shortcut to copy URL

Option 2

(ref How can I copy the repository URL for a line of code in Visual Studio Code?)

  1. Install GitLens plugin in VSCode
  2. Open file from a cloned repo then Cmd+Shift+P > type GitLens: Copy
  3. Run gitlens.copyRemoteFileUrlToClipboard command.