Automatically Close NerdTree When Using Vimade

As the NERDTree README points out, you can automatically close Vim if NERDTree is the only open window by adding this to your configuration:

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

If you are using vimade and Neovim (I couldn’t reproduce in Vim), however, you may see something like this in your terminal after Neovim exits:

Error detected while processing function vimade#Tick[1]..vimade#CheckWindows[3]..provider#python3#Call:
line   18:
Invalid channel: 3

The fix is to run VimadeDisable before automatically quitting, so change the above line in your configuration to this:

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | execute 'VimadeDisable' | q | endif

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.