NerdTree - Показать файл в дереве - PullRequest
90 голосов
/ 07 октября 2011

Есть ли ярлык, который показывает текущий файл на панели каталогов NerdTree.

Как TextMate 'Показать файл в Drawer' - Ctrl + Command + R

Ответы [ 2 ]

166 голосов
/ 08 октября 2011

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.

Я не думаю, что по умолчанию это связано с чем-то, поэтому вам нужно самим связать клавиши.

nmap ,n :NERDTreeFind<CR>

- это то, что появляется в моем .vimrc вместе с

nmap ,m :NERDTreeToggle<CR>
17 голосов
/ 10 февраля 2017

Проверьте это, это автоматизирует операцию синхронизации, всякий раз, когда вы меняете буфер, nerdtree автоматически обновляется (я скопировал с здесь с небольшими изменениями)

" 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()
...