nerdtree icon indicating copy to clipboard operation
nerdtree copied to clipboard

Relative bookmarks

Open Aster89 opened this issue 4 years ago • 1 comments

Description

When a team uses a sandbox-based development everybody it often happens that one frequently works in a few directories, which one would likely set as bookmarks, which are all subdirectories of one single sandbox-specific directory.

For instance, today I might be working on the following directories/files which I want to make bookmarks

/some/path/to/sandboxABC/main-product/some/sub/directory
/some/path/to/sandboxABC/main-product/some/other/sub/directory
/some/path/to/sandboxABC/main-product/some/important/file

where the suffix ABC is generated by the versioning system, or whatever but out of my control; then tomorrow I'll update my sandbox and got a new identifier sandboxXYZ. At this point I'd really like to the bookmarks above to be ported correctly:

/some/path/to/sandboxXYZ/main-product/some/sub/directory
/some/path/to/sandboxXYZ/main-product/some/other/sub/directory
/some/path/to/sandboxXYZ/main-product/some/important/file

I guess something like this could be achieved via some dynamic bookmark which is computed based on the current dir that NERDTree is in. For instance the logic could be "if I am in a subdirectory of /some/path/to/ whose name matches the regex sandbox\w\+, obtain the bookmarks by prepending that directory to the saved relative bookmarks".

Aster89 avatar Sep 27 '21 12:09 Aster89

I like this idea. It will require quite a bit of work to get it right. In the meantime, you can use this workaround.

  1. In NERDTree, use the :EditBookmarks command to open the bookmark list.
  2. Edit the paths as necessary for your new sandbox name.
  3. Save the file.
  4. Restart vim, or run the :call g:NERDTreeBookmark.CacheBookmarks(1) command.

PhilRunninger avatar Sep 29 '21 04:09 PhilRunninger

I'm going to close this issue as not planned since I can't see that good of a reason for having dynamic bookmarks. I think it can be achieved by both editing the bookmark file itself and maybe some symlink trickery, so you can point the bookmark to the workspace symlink and create a new symlink in its place for the sandbox each time it changes.

rzvxa avatar Oct 25 '23 00:10 rzvxa