Skip to content

Instantly share code, notes, and snippets.

@utsengar
Created January 28, 2011 18:24
Show Gist options
  • Save utsengar/800687 to your computer and use it in GitHub Desktop.
Save utsengar/800687 to your computer and use it in GitHub Desktop.
function! NERDTreeQuit()
redir => buffersoutput
silent buffers
redir END
" 1BufNo 2Mods. 3File 4LineNo
let pattern = '^\s*\(\d\+\)\(.....\) "\(.*\)"\s\+line \(\d\+\)$'
let windowfound = 0
for bline in split(buffersoutput, "\n")
let m = matchlist(bline, pattern)
if (len(m) > 0)
if (m[2] =~ '..a..')
let windowfound = 1
endif
endif
endfor
if (!windowfound)
quitall
endif
endfunction
autocmd WinEnter * call NERDTreeQuit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment