2

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.

exomen
  • 355
  • 2
  • 6
  • 20
  • 3
    Does this answer your question? [How can I copy the repository URL for a line of code in Visual Studio Code?](https://stackoverflow.com/questions/63044759/how-can-i-copy-the-repository-url-for-a-line-of-code-in-visual-studio-code) – rioV8 Nov 02 '22 at 04:29

1 Answers1

3

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.
exomen
  • 355
  • 2
  • 6
  • 20
  • This method copies url which is usable for vscode users only: `vscode://eamodio.gitlens/link/r/9f5feef59fe62e4d7687edf1f5cfca285ddbc848?url=git%40github.com%3Acompany%2Frepo.git` My colleague uses another ide. Is it possible to copy a simple browser link like this: `https://github.com/company/repo/blob/branch/apps/admin/src/features/client/client.selectors.ts#L8` Could you explain how, please? – yevt May 12 '23 at 10:30