Skip to content

Instantly share code, notes, and snippets.

@kogakure
Created March 12, 2013 15:17
Show Gist options
  • Select an option

  • Save kogakure/5143767 to your computer and use it in GitHub Desktop.

Select an option

Save kogakure/5143767 to your computer and use it in GitHub Desktop.
Vim: Easy Vim session management
" http://connermcd.com/blog/2013/03/11/easy-vim-session-management/
"
" Make a session: :Mks
" Load a session: source my-session-file.session
command! Mks let g:session = getcwd() <bar> call Mks(g:session)
augroup vimrc
au!
au BufRead *.session let g:session = expand('%:p:h') | so % | bd #
au VimLeave * if exists('g:session') | call Mks(g:session) | endif
augroup end
fun! Mks(path)
exe "mksession! ".a:path."/".fnamemodify(a:path, ':t').".session"
endfun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment