I'm using such sessionopts:

set ssop=blank,buffers,sesdir,folds,localoptions,tabpages,winpos,winsize

The "sesdir" as opposed to "curdir" should store all the paths relative to the directory in which session file is located. Unfortunately there is a line in session file:

args absolute/path/to/file1 absolute/path/to/file2 and/so/on

How do I make vim use only relative paths so I could just put the session file into a git repo and resume my session from any machine?


grosshat's solution doesn't work. Probably need to refer to Zsolt Botyaki's answer over on SO:

You can't do that without setting up a wrapper function for it, AFAIK.

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" 

That sounds strange. When you set sesdir you declare the location of session will be set to be current working directory and all path in the session file will become relative path instead of absolute path.

I've used your sessionopts and it works. I can't find any line related to paths. How are you creating the session file? Standard is:

  1. :mksession [filename]
  2. vim -S [filename]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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