How to open a file in new tab by default in NERDTree?

老子叫甜甜 提交于 2019-12-03 08:08:27

问题


I want a file to be opened in a new tab when I enter or double click it. I know there is t shortcut but I always open a file in a new tab and enter is more confortable for me.


回答1:


Try adding

let NERDTreeMapOpenInTab='\r'

or

let NERDTreeMapOpenInTab='<ENTER>'

to your .vimrc.

HTH




回答2:


s will open the file currently under the cursor in a new vertically split window. Use t to open in a new tab.




回答3:


You may want to add https://github.com/Nopik/vim-nerdtree-direnter plugin as well - it fixes the directory opening problem, so enter on directory node will just expand/collapse, not open new tab.




回答4:


I use following map to do tab traverse :

nnoremap <C-l> gt
nnoremap <C-h> gT



回答5:


Add this to the plugin. It needs to be added to a file such as: ~/.vim/nerdtree_plugin/mymapping.vim. The exact location will depend on what plugin manager you use for vim. e.g. for Plugged it is ~/.vim/plugged/nerdtree/nerdtree_plugin/mymapping.vim

This code adds a mapping for the enter key to open files in a new tab while just expanding/collapsing directories. For the new tabs it also mirrors the NERDTree so it can be shared between tabs.

call NERDTreeAddKeyMap({
  \ 'key': '<CR>',
  \ 'scope': "Node",
  \ 'callback': 'OpenInNewTab',
  \ 'quickhelpText': 'open node' })


" FUNCTION: s:openInNewTab(target) {{{1
function! OpenInNewTab(node)
  if a:node.path.isDirectory
    call a:node.activate()
  else
    call a:node.activate({'where': 't'})
    call g:NERDTreeCreator.CreateMirror()
    wincmd l
  endif
endfunction



回答6:


For the double-click event specifically, it is (only?) possible by slightly changing the NERDtree source code (posted here):

https://stackoverflow.com/a/31570970/5144840



来源:https://stackoverflow.com/questions/8680752/how-to-open-a-file-in-new-tab-by-default-in-nerdtree

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!