If you use vim or neovim on a daily basis and work in large codebases, it is probably not uncommon for you to have 10+ tabs open at a time,
with various splits. Once you close this vim session the layout is lost to the ethers. the mksession command in vim(neovim) can save you,
thus saving the session to a directory, promising to return you to your work exactly how you left it.
However, the problem is most of us accrue many of these session files scattered about, personally I have 41 vim session files,
easily loading them, rememembering the context of each one, and removing stale sessions becomes a hassle. enter vsm (Vim Session Manager),
it allows you to list, open, and remove sessions files, either interactively or by name. It also manages different variations of vim, and allows
you to switch between them. For example you may be a neovide user rather than neovim, vsm currently supports vim, neovim, neovide and gvim.
Currently I have only found one other project which allows more indepth session file management.
However it didn't suit my desires, as it is written in vim script, suffers from useless feature rot, and relies heavily on the xolox misc plugin,
together loading in over 1200 or so lines of vim script just to manage some session files, it also seems to be unmaintained as the
last change recorded was July 6, 2014. Because of this I wrote vsm, it seemed like a better solution to make an external cli program and off load
work from vim and shorten my plugin list as much as possible.
cargo install vsm
Installs the optimized binary to
$HOME/.local/bin
git clone https://github.com/thebashpotato/vsm
cargo install just
just installAn environement variable
VIM_SESSIONSis expected on the system, if it is not definedvsmwill default to~/.config/vim_sessionswhen it looks for your session files. Below are 2 examples for settings the variable in different shells. You can set the path where ever you want.
-
bash/zsh
export VIM_SESSIONS="$HOME/.config/vim_sessions" -
fish
set -Ux VIM_SESSIONS "$HOME/.config/vim_sessions"
vsmcan load, list and remove session files, but it can't create them. That is the job ofvim.
Add the below snippet to your
.vimrcorinit.vimto make creating new session files much easier. Now innormal modeyou can pressmkto quickly save your session file.
if isdirectory(expand($VIM_SESSIONS))
" Create a new sesion file (must give the file a unique name
nnoremap mk :mksession $VIM_SESSIONS/
" Overwrite an existing sessioon file with your current layout
nnoremap mo :mksession! $VIM_SESSIONS/
else
nnoremap mk :echo "VIM_SESSIONS directory does not exist"<CR>
nnoremap mo :echo "VIM_SESSIONS directory does not exist"<CR>
endifOnly requires just to bootstrap all tools and configuration.
cargo install just
just init # setup repo, install hooks and all required toolsTo run:
just runTo test:
just testBefore committing your work:
just pre-commitTo see all available commands:
just listPRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
This project is licensed under:
