Share marks in vim across machines

Viewed 42

I use a few different machines and I was wondering if there was a way to store or share marks in files that are opened on the different machines.

If so, how could this be done? I am fine saving/re-storing a helper file in the .vim directory if that is necessary to do the above.

This would be for both lowercase and uppercase marks. I suppose one option would be to put the .viminfo in a git repository and share that between machines, but I'm wondering what unintended consequences that might have. Currently I have:

set viminfo='100,f1,n~/.vim/viminfo

Note that I'm not interested in storing it across sessions on the same machine, but different computers (one local one in aws).

1 Answers

My advice is to use a separate session-like file that only stores marks. The command :wviminfo can write a separate file. So the plan is: save &viminfo and clear it, write a file with marks, restore &viminfo.

function! SaveMarks()
    let save_vim = &viminfo " Save viminfo
    set &viminfo='100,:0,/0,<0,@0 " Clear viminfo - store only file marks for 100 files
    wviminfo! marks.vim
    let &viminfo = save_vim " Restore viminfo
endfunction

Copy the file to the other host, read it using :rviminfo:

:rviminfo! marks.vim
Related