我想保存一个打开文件列表(:ls),退出gvim,启动gvim,重新打开所有以前打开的文件.我不想使用:mksession因为它无法正常工作(可能是由于我正在使用的一些插件)
Jas*_*oof 23
也许错误/冲突:mksession只有你有以下部分:mksession启用你不关心.
试试这个:
:set sessionoptions=buffers
:mksession
Run Code Online (Sandbox Code Playgroud)
另一个答案建议使用会话管理器插件,它们很棒。但我有一个非常轻量级的替代品,我会留在这里供后代使用。(因为这个问题已经有一段时间了。)
下面的代码在关闭时自动保存当前会话,并设置一个关键命令来手动重新加载它(当我真的想要一个包含新文件的新会话时很方便)。如果你真的想在 vim 再次启动时无条件地恢复之前的会话,取消 'VimEnter' 行的注释。
作为奖励,这还可以通过按键手动保存和恢复单独的会话。
" Automatically save the current session whenever vim is closed
autocmd VimLeave * mksession! ~/.vim/shutdown_session.vim
" <F7> restores that 'shutdown session'
noremap <F7> :source ~/.vim/shutdown_session.vim<CR>
" If you really want to, this next line should restore the shutdown session
" automatically, whenever you start vim. (Commented out for now, in case
" somebody just copy/pastes this whole block)
"
" autocmd VimEnter source ~/.vim/shutdown_session.vim<CR>
" manually save a session with <F5>
noremap <F5> :mksession! ~/.vim/manual_session.vim<cr>
" recall the manually saved session with <F6>
noremap <F6> :source ~/.vim/manual_session.vim<cr>
Run Code Online (Sandbox Code Playgroud)
用户可以使用上面提到的 'sessionoptions' 选项为自己定义会话中的内容: help sessionoptions