Question

VSCode Copy Relative Path with posix forward slashes

VSC newbie here.

I'm trying to right-click on my projects' files and selecting Copy Relative Path, the thing is I get the path like this: node_modules\bootstrap\dist\css\bootstrap.min.css

when what I actually need is this: node_modules/bootstrap/dist/css/bootstrap.min.css

Where can I change these settings to avoid the manual editing, It's really time consuming.

Thanks for your help.

 46  15212  46
1 Jan 1970

Solution

 68

As of vscode 1.59 you can enable using the / separator even on Windows for the Copy Relative Path command.

Explorer: Copy Relative Path Separator set to /.

explorer.copyRelativePathSeparator

  • auto (default): Uses operating system specific path separation character
  • /: Use slash as path separation character
  • \\: Use backslash as path separation character

See https://github.com/microsoft/vscode/issues/56279

enter image description here


For the same ability to designate the path separator for the copy full path (tab context menu: Copy Path) command, there is an issue with a PR awaiting resolution: Allow to configure the which slash is used when copying a path.

2021-07-14

Solution

 1

I think it's because you used Windows, which uses \ instead of / in paths. I suggest using raw strings in the path. For example: r'node_modules\bootstrap\dist\css\bootstrap.min.css'.

Another way to change all the \ to / is by using the replace function in vscode!

2020-09-16