i am trying to find the best way to save marks for each project.
i currently do a :mks! project_name.vim for my session. this does
not save the marks.
is the best way to do this by :wviminfo and :rviminfo?
If you go to
:help 21.4
and search
/mark
you'll land in the "SESSIONS AND VIMINFO" section where it
details your conundrum (that sessions don't store marks), and it
suggests there that you use it in concert with wviminfo/rviminfo.
So you're correct that this seems to be the best way to do it.
if so, does anyone have any suggestions on how to automate this somehow?
The above-mentioned help lacks any ideas on how to automate this.
You might do something like wrap the following in a pair of
functions to save and restore the whole schlemiel:
" get the name of the directory the current file is in
let l:fname = (split(expand('%:p:h'), '\\')[-1])
" in pre-vim7, the above could be done as
" let l:fname = matchstr(expand('%:p:h'), '\w*$')
exec 'mksession! '.getcwd().'/'.l:fname.'.sess'
exec 'wviminfo! '.getcwd().'/'.l:fname.'.vim'
and a counterpart function to do something like
" get the name of the directory the current file is in
let l:fname = (split(expand('%:p:h'), '\\')[-1])
" in pre-vim7, the above could be done as
" let l:fname = matchstr(expand('%:p:h'), '\w*$')
exec 'source! '.getcwd().'/'.l:fname.'.sess'
exec 'rviminfo! '.getcwd().'/'.l:fname.'.vim'
Tweak as needed.
HTH,
-tim