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

Session save in current folder

Open iwkse opened this issue 10 years ago • 4 comments

Hi, is it a way to save a session file in the current folder? I think it's handy to have the ability to save the session within the source tree.

iwkse avatar Jan 19 '15 22:01 iwkse

Not a convenient option, but you could use the g:session_directory variable to specify where to save your session files. There might even be a way to automate setting it when you switch to a project folder, or open a certain type of file (but I don't know enough about vim scripting to know how to do that).

ghost avatar Feb 27 '15 17:02 ghost

I've not tested this much, but the following seems to work:

let g:session_directory = "./" 
let g:session_default_name = "session"
let g:session_autoload = "yes"
let g:session_autosave = "yes"

smallhadroncollider avatar Sep 30 '16 09:09 smallhadroncollider

Or, if you want them stored in a single location (e.g. for syncing between computers):

let g:session_default_name = substitute(getcwd(), "\/", "_", "g")
let g:session_autoload = "yes"
let g:session_autosave = "yes"

e.g. would store a project opened in /Volumes/Projects/onions in ~/.vim/sessions/_Volumes_Projects_onions.vim

smallhadroncollider avatar Sep 30 '16 09:09 smallhadroncollider

@smallhadroncollider I actually prefer using

let g:session_directory = "./" 
let g:session_default_name = "session"
let g:session_autosave = "yes"

then starting vim with vim -S so that i don't accidentally open the session if i dont want to.

Hopefully this is useful for someone

dylan-chong avatar Jun 15 '18 08:06 dylan-chong