vim-session
vim-session copied to clipboard
Session save in current folder
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.
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).
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"
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 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