10 years ago
Adds mappings to store up to 10 vim sessions which can be loaded or saved whenever.
Make .sessions directory first or this won't work!
mkdir ~/.vim/.sessions
Usage: s# (replace # with a number 1-9) saves the current tab/split layout to that "file". l# (replace # with a number 1-9) loads the tab/split layout previously saved to that "file".
Also, sq saves to the "current" session then quits ss saves to the "current" session ll loads the "current" session (so you can get right back to where you were.
Give it a go, works for me and is quick and easy. Easy to expand the number of save files to whatever you need.
" Quick save current session and quit nnoremap <leader>sq :mksession! ~/.vim/.sessions/last.vim<cr>:qall<cr> " Quick save current session nnoremap <leader>ss :mksession! ~/.vim/.sessions/last.vim<cr> " Quick load last session nnoremap <leader>ll :tabonly<cr>:source ~/.vim/.sessions/last.vim<cr> " Saves sessions 1-9 nnoremap <leader>s1 :mksession! ~/.vim/.sessions/s1.vim<cr> nnoremap <leader>s2 :mksession! ~/.vim/.sessions/s2.vim<cr> nnoremap <leader>s3 :mksession! ~/.vim/.sessions/s3.vim<cr> nnoremap <leader>s4 :mksession! ~/.vim/.sessions/s4.vim<cr> nnoremap <leader>s5 :mksession! ~/.vim/.sessions/s5.vim<cr> nnoremap <leader>s6 :mksession! ~/.vim/.sessions/s6.vim<cr> nnoremap <leader>s7 :mksession! ~/.vim/.sessions/s7.vim<cr> nnoremap <leader>s8 :mksession! ~/.vim/.sessions/s8.vim<cr> nnoremap <leader>s9 :mksession! ~/.vim/.sessions/s9.vim<cr> " Loads sessions 1-9 nnoremap <leader>l1 :tabonly<cr>:source ~/.vim/.sessions/s1.vim<cr> nnoremap <leader>l2 :tabonly<cr>:source ~/.vim/.sessions/s2.vim<cr> nnoremap <leader>l3 :tabonly<cr>:source ~/.vim/.sessions/s3.vim<cr> nnoremap <leader>l4 :tabonly<cr>:source ~/.vim/.sessions/s4.vim<cr> nnoremap <leader>l5 :tabonly<cr>:source ~/.vim/.sessions/s5.vim<cr> nnoremap <leader>l6 :tabonly<cr>:source ~/.vim/.sessions/s6.vim<cr> nnoremap <leader>l7 :tabonly<cr>:source ~/.vim/.sessions/s7.vim<cr> nnoremap <leader>l8 :tabonly<cr>:source ~/.vim/.sessions/s8.vim<cr> nnoremap <leader>l9 :tabonly<cr>:source ~/.vim/.sessions/s9.vim<cr>