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 confortabl
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': '',
\ '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