首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >NerdTree -在树中显示文件

NerdTree -在树中显示文件
EN

Stack Overflow用户
提问于 2011-10-08 03:52:31
回答 5查看 30.7K关注 0票数 115

是否有在NerdTree目录面板中显示当前文件的快捷方式。

就像TextMate‘显示抽屉里的文件’- Ctrl+Command+R

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2011-10-08 04:01:17

在: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>
票数 207
EN

Stack Overflow用户

发布于 2017-02-10 16:42:12

看看这个,它自动同步操作,当你改变缓冲区时,nerdtree会自动刷新(我从here复制的,只做了很小的修改)

" 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()
票数 23
EN

Stack Overflow用户

发布于 2020-01-30 07:21:19

这也可能只是一个评论。在当前版本中,切换NerdTree并使用SyncTree会导致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()

function! ToggleNerdTree()
  set eventignore=BufEnter
  NERDTreeToggle
  set eventignore=
endfunction
nmap <C-n> :call ToggleNerdTree()<CR>
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7692233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档