2011-10-07 15 views

risposta

137

in: h NERDTree:

:NERDTreeFind             :NERDTreeFind 
    Find the current file in the tree. If no tree exists for the current tab, 
    or the file is not under the current root, then initialize a new tree where 
    the root is the directory of the current file. 

Io non credo che sia legato a qualche cosa di default, in modo da avere a fai un keybind te stesso.

nmap ,n :NERDTreeFind<CR> 

è ciò che appare nel mio Vimrc, insieme con

nmap ,m :NERDTreeToggle<CR> 
+0

Il keymapping funziona, ma come invocare NERDTreeFind all'interno di vim? – toszter

+7

@toszter just': NERDTreeFind' – Thomas

+0

C'è un modo per impostarlo per farlo ogni volta che NERDTree viene creato all'interno di quella scheda? –

7

check this out, automatizza l'operazione di sincronizzazione, ogni volta che si cambia buffer, il nerdtree verrà automaticamente aggiornata (ho copiato da here con piccole modifiche)

" Check if NERDTree is open or active 
function! 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! SyncTree() 
    if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff 
    NERDTreeFind 
    wincmd p 
    endif 
endfunction 

" Highlight currently open buffer in NERDTree 
autocmd BufEnter * call SyncTree() 
+0

Grazie, ho cercato questo per così tanto tempo! :) – Gnagno