diff --git a/.vim/autoload/vimrc.vim b/.vim/autoload/vimrc.vim --- a/.vim/autoload/vimrc.vim +++ b/.vim/autoload/vimrc.vim @@ -87,3 +87,20 @@ func! vimrc#SafeFilterFile(cmd) call delete(errors) endtry endfunc + +if has('perl') + func! vimrc#PruneSession() abort + perl <Name || -d _ || (-M _ >= 30) } + grep { $_->Name } VIM::Buffers(); + + while (my $b = shift @bufs) { + VIM::Msg 'pruned: ' . $b->Name, 'Comment'; + VIM::DoCommand 'bwipeout ' . $b->Number; + } + VIM::DoCommand 'bprev' + unless $curbuf->Name; +END_PERL + endfunc +endif