vim-session icon indicating copy to clipboard operation
vim-session copied to clipboard

Persist markers into session?

Open eduardoarandah opened this issue 4 years ago • 1 comments

I’ve been looking all over the place to save/load my markers in a session instead of globally (which I find pretty dumb tbh)

So, let’s say I have an “I” marker for the info.txt in each project, doesn’t mix with the info.txt in another project.

I’ve read that :wv and :rv let you create a viminfo file in another location. And that’s exactly what I want to happen when I have a session.

Is this possible?

If so, would you consider integrating it? I’d like to contribute but have no idea about vimscript 😅

eduardoarandah avatar Aug 23 '19 13:08 eduardoarandah

This provides a great idea to create a viminfo file that autosaves/autoloads with same name as the session:

https://vi.stackexchange.com/questions/17091/can-capitalized-marks-be-saved-in-session-instead-of-viminfo/17093#17093

command! -bang -complete=file -nargs=? Mksession mksession<bang> <args> |
      \ let [s:viminfofile, s:viminfo] = [&viminfofile, &viminfo] |
      \ try |
      \   let [&viminfofile, &viminfo] = [v:this_session . '.viminfo', 'f'] |
      \   wviminfo! |
      \ finally |
      \   let [&viminfofile, &viminfo] = [s:viminfofile, s:viminfo] |
      \ endtry

augroup ViminfoSessionRestore
  autocmd!
  autocmd SessionLoadPost * |
        \ let [s:viminfofile, s:viminfo] = [&viminfofile, &viminfo] |
        \ try |
        \   let [&viminfofile, &viminfo] = [v:this_session . '.viminfo', 'f'] |
        \   rviminfo! |
        \ finally |
        \   let [&viminfofile, &viminfo] = [s:viminfofile, s:viminfo] |
        \ endtry
augroup END

so your sessions directory would look like:

project1
project1.viminfo
project2
project2.viminfo

I tried it but couldn't make progress

eduardoarandah avatar Aug 23 '19 15:08 eduardoarandah