Closed Dbz closed 6 years ago
I am looking into this.
That is awesome, thank you! I appreciate the effort 🎉
The following works :
function! s:preserve_alt_buffer()
let l:alternate = fnameescape(expand('#'))
if !empty(l:alternate)
call system('echo "let @#=\"'.l:alternate.'\"" >> '.v:this_session)
endif
endfunction
augroup ProsessionPreserveAlt
au!
autocmd VimLeave * call s:preserve_alt_buffer()
augroup END
I don't think there are any side effects to doing this, but let me know if you face any issues.
NOTE : To give you some context, the actual session persisting logic is within tpope/vim-obsession. As of now I don't see a better API to achieve this other than just add your logic within VimLeave (not VimLeavePre) autocmd. But it works.
This works! Thank you! Really, this is awesome. I'll make an issue on vim-obsession and see if tpope is willing to accept this added functionality.
Hello,
I'd like to store the alternative file in the session so that I can close vim, open it back up and type
<c-^>
and automatically switch to the previous buffer that I was using.I found a vi stack exchange answer which can do this:
However, adding this to my vimrc doesn't solve the problem because vim-prosession isn't calling the new
MkSession
instead ofmksession
.Is there a way for me to add something to my vimrc to make this work, or would it be possible to add an option to vim-prosession to save the alternative file so that it's available when opening up the session?
Perhaps I could change
autocmd VimLeave * exec 'mksession!' g:prosession_dir . 'last_session.vim'
to beautocmd VimLeave * exec 'MkSession' g:prosession_dir . 'last_session.vim'
on my local copy? Alas, this didn't work for me, so there is probably more to it :(