So I've been using NERDTree in vim as it adds great functionality being able to browse around the file system. And with the Bookmarks capabilities it works great for switching between projects.
However, I've started using Marks more and more in vim and wanted to know if anyone knew of a plugin that allowed you to have sets of marks. Like I want `C to go to the config file in the project I'm currently working on. I can set it each time I switch projects, but was wondering if anyone knew of a good way to package them.
In just thinking about it, I think it would be awesome if it would just read a file when you got into a directory (like switching between bookmarks with NERDTree...).
Anyways, anyone know of anything like that?
So it turns out that marks are not stored in the session, but are stored in the viminfo file! So I used the code from your vimrc as a basis and the code found at the bottom of the section on sessions in the vim help files to create a function that will allow me to save save the session and viminfo file. Creating basic project management that works great for me!
Here is the code I ended up with.
if version >= 700
" localoptions has to be here:
" for some reason, new session loading code fails to set filetype of files in session
set sessionoptions=blank,tabpages,folds,localoptions,curdir,resize,winsize,winpos
endif
command! -nargs=1 Project :call LoadProject('<args>')
command! -nargs=+ SaveProject :call SaveProject('<args>')
let s:projectloaded = 0
let s:loadingproject = 0
let s:projectname = ''
function! LoadProject(name)
let s:projectloaded = 1
let s:projectname = a:name
exe "source ~/vimfiles/projects/".a:name.".vim"
exe "rviminfo! ~/vimfiles/projects/".a:name.".viminfo"
endfunction
function! SaveProject(name)
if a:name ==# ''
if s:projectloaded == 1
let pname = s:projectname
endif
else
let pname = a:name
endif
if pname !=# ''
let s:projectloaded = 0
let s:projectname = ''
exe "mksession! ~\\vimfiles\\projects\\".pname.".vim"
exe "wviminfo! ~\\vimfiles\\projects\\".pname.".viminfo"
endif
endfunction
autocmd VimLeave * call SaveProject()