1介绍
这适用于NERD树版本4.2.0.
2在新选项卡中打开目录和文件
如果要在新选项卡中打开目录和文件,只需将以下行添加到〜/ .vimrc.
let g:NERDTreeMapOpenInTabSilent = '<2-LeftMouse>'
3仅在新选项卡中打开文件
" opens a file in a new tab " KeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set " stayCurrentTab: if 1 then vim will stay in the current tab,if 0 then vim " will go to the tab where the new file is opened function! s:openInTabAndCurrent(keepWindowOpen,stayCurrentTab) if getline(".") ==# s:tree_up_dir_line return s:upDir(0) endif let currentNode = s:TreeFileNode.GetSelected() if currentNode != {} let startToCur = strpart(getline(line(".")),col(".")) if currentNode.path.isDirectory call currentNode.activate(a:keepWindowOpen) return else call s:openInNewTab(a:stayCurrentTab) return endif endif endfunction
并更换线
nnoremap <silent> <buffer> <2-leftmouse> :call <SID>activateNode(0)<cr>
有:
nnoremap <silent> <buffer> <2-leftmouse> :call <SID>openInTabAndCurrent(0,1)<cr>