2011-10-07 32 views

Trả lời

137

tại: 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. 

Tôi không nghĩ rằng đó là ràng buộc bất cứ điều gì theo mặc định, vì vậy bạn phải làm một keybind chính mình.

nmap ,n :NERDTreeFind<CR> 

là những gì xuất hiện trong vimrc của tôi, cùng với

nmap ,m :NERDTreeToggle<CR> 
+0

Thao tác keymapping hoạt động, nhưng cách gọi NERDTreeFind trong vim? – toszter

+7

@toszter chỉ ': NERDTreeFind' – Thomas

+0

Có cách nào để thiết lập nó để làm điều này bất cứ khi nào NERDTree được tạo trong tab đó? –

7

Kiểm tra này ra, nó tự động hóa hoạt động đồng bộ, bất cứ khi nào bạn thay đổi bộ đệm, các nerdtree sẽ tự động làm mới bản thân (Tôi sao chép từ here với những sửa đổi nhỏ)

" 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

Cảm ơn bạn, tôi đã tìm kiếm điều này trong một thời gian dài! :) – Gnagno

Các vấn đề liên quan