NerdTree - display a file in a tree

Is there a shortcut that shows the current file in the NerdTree directory pane.

Like TextMate 'Display File in Drawer' - Ctrl + Command + R

+71
vim nerdtree
07 Oct '11 at 19:52
source share
2 answers

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. 

I do not think that it is tied to anything by default, so you need to make the key itself.

 nmap ,n :NERDTreeFind<CR> 

is what appears in my .vimrc, along with

 nmap ,m :NERDTreeToggle<CR> 
+135
07 Oct '11 at 20:01
source share

Check this, it automates the synchronization operation, when you change the buffer, nerdtree is automatically updated (I copied from here with tiny modifications)

 " 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() 
+6
Feb 10 '17 at 8:42 on
source share



All Articles