Created
October 5, 2013 19:10
-
-
Save cp/6844940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on | |
set tabstop=2 | |
autocmd vimenter * NERDTree | |
autocmd Vimenter * wincmd p | |
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