0

Is there any way to edit the symlink path in vscode?

For example in my git ui it shows the symlink path I use, "../../path"

It just opens the destination file when I click on it in the vscode explorer and it doesn't seem like there's a way to inspect and edit the actual path.

Harry
  • 52,711
  • 71
  • 177
  • 261

1 Answers1

1

No, it looks like that isn't possible at the moment. The short answer is no, because it's not currently possible without customizations that (as far as I'm aware) don't exist yet and may be non-trivial to make.

The long answer is, according to this similar question posted earlier (among other sources):

  1. The simplest way to edit a symink for you (assuming a Unix-like environment) would be to right-click it in the explorer, then select "Open in Integrated Terminal" and use something like ln -sfn source.ext link.ext within the terminal (-f overwrites & -n allows folders).
  2. If you're on Windows 10 (possibly 11 as well?) or earlier, you can use this shell extension to add a right-click option to edit symlink properties in a 'text editor' of sorts, as mentioned here.
  3. Something similar to the above extension probably exists or would be possible to make on Linux or even VS Code specifically, but would probably take some tinkering.
  4. Emacs' writable dired mode (wdired), shown in one of the answers linked to the previous question, seems to be the closest thing to what you're asking. Not possible in VS Code unless there's a custom extension or setup somewhere that I missed.
Ryan Cargan
  • 76
  • 1
  • 3
  • I guess the answer is no, though I appreciate the alternatives. If you just write no I'll give you the award. – Harry Oct 19 '22 at 22:51
  • @Harry Clarified that the short answer is no. I can imagine some workarounds to sort of get what you want, but may I ask what exactly you're trying to do? Do you frequently need to work with symlinks? – Ryan Cargan Oct 20 '22 at 02:16
  • Appreciate the followup, I have a /brainstorm dir and a /src dir with my actual code. I would like to be able to access the brainstorm .md notes in the src, right where I'm working on them while also keeping them easily browsable in the /brainstorm dir. A symlink would be ideal, there's a vscode extension that can create symlinks but it's abs path instead of relative which doesn't work for me. – Harry Oct 20 '22 at 03:57
  • 1
    @Harry A solution like [this](https://superuser.com/questions/633605/how-to-create-symbolic-links-to-all-files-class-of-files-in-a-directory) with a bit of Bash scripting may be your best option. Otherwise, you could dig into the source code of the extension and edit the part where `ln` is called to add a `--relative`/`r` flag. – Ryan Cargan Oct 20 '22 at 05:26