Synchronize nerdtree highlight with buffer switch. #184

Closed
rahulkmr opened this Issue Jul 13, 2012 · 2 comments

Comments

Projects
None yet
3 participants
@rahulkmr

Is there a way nerdtree can auto-sync with buffer switch? I can do it manually with nnoremap ,i :NERDTreeFind<CR><c-w><c-w> but I am looking for auto-sync.

I dived into vim docs to look for events I can bind to, but BufRead gets called only once, when the file is read into the buffer; and BufEnter can't be used as everytime I enter the buffer, it will call NERDTreeToggle sending me back to nerd tree pane. Any ideas?

@rahulkmr

This comment has been minimized.

Show comment Hide comment
@rahulkmr

rahulkmr Jul 13, 2012

I mainly use bufexplorer for switching buffers. I solved my problem by hooking NERDTreeFind with bufexplorer.

function! ChangeBuffer()
    if bufwinnr(t:NERDTreeBufName) != -1
        exe "normal! :NERDTreeFind\<cr>\<c-w>\<c-w>"
    endif
endfunction
let g:BufExplorerFuncRef = function('ChangeBuffer')

I mainly use bufexplorer for switching buffers. I solved my problem by hooking NERDTreeFind with bufexplorer.

function! ChangeBuffer()
    if bufwinnr(t:NERDTreeBufName) != -1
        exe "normal! :NERDTreeFind\<cr>\<c-w>\<c-w>"
    endif
endfunction
let g:BufExplorerFuncRef = function('ChangeBuffer')
@obxhdx

This comment has been minimized.

Show comment Hide comment
@obxhdx

obxhdx Aug 4, 2012

I believe you can achieve the same using autocmd BufWinEnter * NERDTreeFind.

obxhdx commented Aug 4, 2012

I believe you can achieve the same using autocmd BufWinEnter * NERDTreeFind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment