preservim / nerdtree

A tree explorer plugin for vim.
Do What The F*ck You Want To Public License
19.66k stars 1.45k forks source link

How to automatically close tab if nerdtree is the only window in the tab? #1421

Closed backpropper closed 5 months ago

backpropper commented 5 months ago

Before creating an issue, take some time to search these resources. It's possible that someone else has already asked your question and gotten an answer.

State Your Question

I want to close the tab when nerdtree is the only remaining window in the current tab after I close the file in another window.

I'm using the following: autocmd BufEnter * if tabpagenr('$') > 1 && !len(filter(tabpagebuflist(), 'getbufvar(v:val,"&ft") != "nerdtree"')) | tabclose | endif

Can someone please help? This isn't working and I get an error when nerdtree is the only window in a tab.

backpropper commented 5 months ago

Found the solution in the README