Vscode: Feature request: Copy reference/relative path

Created on 23 Sep 2016  路  11Comments  路  Source: microsoft/vscode

Pretty useful and implemented in IDEs like IntelliJ IDEA: ability to copy reference/relative path to the file in project tree, or to current line/definition in editor.

At this point there's a "Copy Path" menu item, which is pretty useless to me, always have to paste it, modify and then send to colleagues.

What I expect is actually a path like src/app.js instead of /Users/.../Repo/.../src/app.js. And src/app.js:123 when copied from editor, pointing to specific line.

Mostly switched to VSCode, so hope it'll be even more convenient.
Thanks!

*extension-candidate feature-request

Most helpful comment

Sounds like an extension candidate 馃憤

All 11 comments

Sounds like an extension candidate 馃憤

@z-ax Something along these lines exists in marketplace, though it doesn't really satisfy your requirement I guess:

https://marketplace.visualstudio.com/items?itemName=alexdima.copy-relative-path

Well, I added it as feature request because I'd even replace current (barely used) "Copy Path".
Not sure about the most.

Also, often need a reference to the line as well.

@z-ax Fully agree on the line reference, that would be a very useful feature for pointing colleagues to a specific code line.

I'd have started an extension for this, just was a bit reluctant on flooding the marketplace with dozens of extensions that more or less do the same thing.

But your proposal seems different enough compared to the existing ones to warrant its own extension.

@z-ax Give this a spin, maybe it helps:

https://marketplace.visualstudio.com/items?itemName=bgse.relative-path-and-line

Certainly not ideal, but at least provides a way to quickly copy some file/line reference suitable for quickopen.

If using Linux, you need xclip installed, not sure about Windows/OSX, but Windows probably works out of the box.

@bgse thanks, will get this, with hope that it'll become a part of IDE some time :)

@bgse great extension, thks
Is there a way to add those commands to the right click menu?
It would be nice to right click on a line and copy the file path with the reference to the line you are clicking on

@canda I already had context menu integration in mind, definitely for file explorer, but your idea sounds very interesting too.

Repo is here, in case you want to open an issue for your suggestion or make a PR:

https://github.com/bgse/relative-path-and-line

+1 on this. It can be an absolute time sink if you restructure your files within a project and need to adjust all the relative imports.

We try to keep VS Code lean and we think the functionality you're asking for is great for a VS Code extension. Maybe you can already find one that suits you in the VS Code Marketplace. Just in case, in a few simple steps you can get started writing your own extension. See also our issue reporting guidelines.

Happy Coding!

What? Are you serious?

Was this page helpful?
0 / 5 - 0 ratings