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

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.


Solution 1:

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

Solution 2:

Try adding

let NERDTreeMapOpenInTab='\r'

or

let NERDTreeMapOpenInTab='<ENTER>'

to your .vimrc.

Solution 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.

Solution 4:

As described in section NERDTreeCustomOpenArgs of the NerdTree help, you can use this option to control the opening behavior of files and directories. Add the following statement to your .vimrc:

let NERDTreeCustomOpenArgs={'file':{'where': 't'}}

This ensures in this case that only files in a new tab are opened. All other combinations can be found in the help.

Solution 5:

I use following map to do tab traverse :

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