事實證明,標記並不存儲在session中,而是存儲在viminfo文件中!因此,我使用vimrc中的代碼作爲基礎,並在vim help files的會話部分的底部找到代碼來創建一個函數,該函數將允許我保存會話和viminfo文件。創建適合我的基本項目管理!
這是我結束的代碼。
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()
謝謝。這段代碼適合我,** + 1 **。大寫的標記是驚人的,現在我不會失去它們中的任何一個。 – Birei 2013-10-05 14:52:08