Ⅰ. 插件描述
Vim plugin for working with sessionsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'bgrohman/vim-bg-sessions'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'bgrohman/vim-bg-sessions'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'bgrohman/vim-bg-sessions'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/bgrohman/vim-bg-sessions
Ⅳ. 文档说明
# vim-bg-sessions
Vim plugin for saving and loading sessions
Features
- Save and load sessions by name.
- Tab autocompletion of session names when saving or loading sessions.
- Automatically save the "latest" version of a named session while keeping the original session intact.
- Delete sessions by name.
- Automatically save your session whenever you quit Vim using a session named "last".

Installation
Install vim-bg-sessions like you would any other Vim plugin.
For Pathogen:
cd ~/.vim/bundles
git clone https://github.com/bgrohman/vim-bg-sessions.gitUsage
Commands
:Sessions
Lists all saved sessions.
:SaveSession [session_name]
Saves your current sessions. If session_name is provided, a session will be saved with that name. Otherwise, the session will be saved with the name of "last".
When saving a named session, the "last" session is also updated.
Use tab for session name autocompletion.
Example: Save a session named "myFirstSession"
:SaveSession myFirstSession:LoadSession [session_name]
Loads a session. If session_name is provided, the session by that name will be loaded. Otherwise, the session named "last" will be loaded. Use tab for session name autocompletion.
Example: Load a session named "myFirstSession"
:LoadSession myFirstSessionExample: Load your last session from the last time you closed Vim
:LoadSession
or
:LoadSession lastExample: Load the "latest" version of a session named "myFirstSession"
You've saved a session named "myProject" for a particular project, and you want to be able to always return to that session, so you don't re-save it after continuing your work (e.g. opening additional buffers/windows/tabs). But you also want to be able to return to your last state after you loaded that session, including all of the changes since the "myProject" session was loaded. This plugin will automatically save a session named "myProject_latest" any time you enter a new buffer.
:LoadSession myFirstSession_latest:DeleteSession session_name
Deletes the session named session_name. Use tab for session name autocompletion.
Example: Delete a session named "myFirstSession"
:DeleteSession myFirstSessionOptions
Saved Session Directory
Session files are stored in the directory provided by the global variable g:bg_sessions_dir which is set to "~/.vim-sessions" by default.