Created
May 5, 2014 15:07
-
-
Save ashwin/3c6a40b2d1245f1c5b96 to your computer and use it in GitHub Desktop.
Highlight current file in NERDTree
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
" Check if NERDTree is open or active | |
function! rc:isNERDTreeOpen() | |
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1) | |
endfunction | |
" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable | |
" file, and we're not in vimdiff | |
function! rc:syncTree() | |
if &modifiable && rc:isNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff | |
NERDTreeFind | |
wincmd p | |
endif | |
endfunction | |
" Highlight currently open buffer in NERDTree | |
autocmd BufEnter * call rc:syncTree() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work.
I tried to use this https://stackoverflow.com/questions/7692233/nerdtree-reveal-file-in-tree but got
b:NERDTree
is undefined.