When I have a NERDtree panel and I save a Vim session (mksession [filename]), then open the session (vim -S filename), the panel is opened and tagged \"NERDtree\" but is not pop
Another solution based on stevelove's:
fun! Mksession(name) let need_tree = g:NERDTree.IsOpen() NERDTreeClose execute "mksession! " . a:name if need_tree call writefile(readfile(a:name)+['NERDTree'], a:name) NERDTree endif endfun command! -nargs=1 Mksession call Mksession()