developer tip

NerdTree-트리에 파일 표시

optionbox 2020. 8. 30. 08:12
반응형

NerdTree-트리에 파일 표시


NerdTree 디렉토리 패널에 현재 파일을 표시하는 바로 가기가 있습니까?

TextMate '드로어에 파일 표시'처럼-Ctrl + Command + R


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>

이것을 확인하면 동기화 작업이 자동화됩니다. 버퍼를 변경할 때마다 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()

참고 URL : https://stackoverflow.com/questions/7692233/nerdtree-reveal-file-in-tree

반응형