I'm trying to save my session in Vim with relative paths to open files. With cur_dir
in sessionoptions
, the paths to files will be relative wrt. current directory, but the session file contains cd /path/to/base/directory
command:
...
cd /path/to/base
badd +0 relpath1/file
badd +0 relpath2/file
...
If I leave curdir
out of sessionoptions, the cd
command disappears, but file paths will be absolute:
badd +0 /path/to/base/relpath1/file
badd +0 /path/to/base/relpath2/file
Is there a way to have only relative paths wrt. to whatever was the current directory when the session was created -- without plugins or writing scripts? So that the session file would only have:
badd +0 relpath1/file
badd +0 relpath2/file
My ultimate goal is to have a session file that I can copy around, e.g. from SVN checkout to another.
You can't do that without setting up a wrapper function for it, AFAIK.
E.g. something like:
function! MakeSession()
let b:sessiondir = getcwd()
let b:filename = b:sessiondir . '/session.vim'
exe "mksession! " . b:filename
exe "edit! " . b:filename
exe "g:^cd :d"
exe "x"
endfunction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With