0

I am trying to manage multiple projects each with multiple files so:

project1
            ----src
               file1.cpp, ..., file10.cpp
            ----include
               incl1.h, ..., incl10.h

project2
            ----src
               file1.cpp, ..., file10.cpp
            ----include
               incl1.h, ..., incl10.h
    

I would like to save bookmark information for a project locally as a file under each projectx (x=1 or 2) folder itself as opposed to saving it globally under $home/.vim/.

Is there any way one can have project specific bookmarks saved locally (in the project folder itself) that is also portable across machines accessing the same folder (i.e., the paths saved necessarily have to be relative and not absolute.)?

I tried to setup .viminfo thus via the .vimrc based on a suggestion here:

set viminfo=%,<800,'100,/50,:100,f1,n./.viminfo

This saves the viminfo file in the projectx folder. However, this .viminfo file also stores the path to marks using absolute path and not relative paths as a result of which, it is not portable.

2
  • Can you give more information on what kind of bookmarks you want? AFAIK the easy ways are sessions or global marks, neither of which is likely to be portable. Also note that plugin requests are off-topic: I encourage you to edit the question to ask how to solve your problem (and perhaps an answer will say “here’s a plugin”).
    – D. Ben Knoble
    Commented Sep 4, 2021 at 11:41
  • I have edited to ask the question specifying my particular problem.
    – Tryer
    Commented Sep 4, 2021 at 16:19

1 Answer 1

1

I have decided to adopt the following strategy.

The output of $pwd from the projectx folder on one machine contains the words /mnt/c (standing for WSL on Windows), while the other does not.

So, I defined in my .vimrc the following:

let g:machine_run_on_wsl = system("pwd | grep -c '/mnt/c'") 
if g:machine_run_on_wsl == 1    
    set viminfo=%,<800,'100,/50,:100,f1,n./.vim/.viminfowsl 
else 
    set viminfo=%,<800,'100,/50,:100,f1,n./.vim/.viminfoubuntu  
endif

This way, there are two .viminfo files within .\.vim subfolder of projectx. Even though each of these files (.viminfowsl and .viminfoubuntu) has absolute paths, they are the right absolute paths for the respective machine I am currently working on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.