Vim, NERDtree not recovered in session restore

前端 未结 6 1095
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 17:49

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

6条回答
  •  一生所求
    2021-01-30 18:33

    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()
    

提交回复
热议问题