Automatically quit vim if NERDTree is last and only buffer?

A script to do exactly this has been posted on the NERDTree issue list. Checkout https://github. Com/scrooloose/nerdtree/issues#issue/21.

Thanks, that script is precisely what I was looking for. You should probably get the check, but alas, it's too late . .. You'll have to make do with an upvote.

– G33kx0r Dec 29 '10 at 16:22 @Noah: you can change your accepted answer. – yoda May 10 at 4:14 @yoda it is done. – G33kx0r May 12 at 22:34.

A better version appears to be the one used in the janus repo: autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft() " Close all open buffers on entering a window if the only " buffer that's left is the NERDTree buffer function! S:CloseIfOnlyNerdTreeLeft() if exists("t:NERDTreeBufName") if bufwinnr(t:NERDTreeBufName)! = -1 if winnr("$") == 1 q endif endif endif endfunction.

An idea in need of implementation: You could write a function which, when called, checks if the only buffer remaining (or perhaps the only non-help buffer, if you prefer) is a NERDTree buffer and, if so, deletes it (or just quits). Then have an autocmd run it whenever a buffer is deleted / hidden / whatever actually happens when you :q (it shames me to admit I'm not entirely sure! ).

You could :cabbrv q qa but I'd advise against that because you'll forget about it when you actually want q.

I like to do this: cmap bq :bufdo q to close all buffers with two keystrokes in command mode.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions