I know adding the following to ~/.vimrc will autosave a session file in the current directory with the name ‘Session.vim’.
autocmd BufWritePre :mksession!
However, these files would litter up directories. I would rather save the session file to /tmp/[some filename which specifies the directory].
Is there any way to do this?
You can use this expression to generate the file name:
"/tmp/vimSessions/".substitute(expand("%:p:h"),"/","_","g")Ofcourse, you can change the first string to contain whatever directory you want.
UPDATE:
Add this to your
vimrcfile: