views:

35

answers:

2

In NERDTree ShiftT opens file in a new tab, but tab is positioned after the tab in which NERDTree is opened.

It is possible to open the new tab at the end of tabs?

A: 

I suggest you edit the plugin and remap it to :tablast before :tabnew.

Benoit
Isn't possible to overwrite mappings in `.vimrc`?
kfl62
I am not sure in what order scripts will be read. `:scriptnames` will tell you. If `.vimrc` comes after NERDTree, you can remap it inside your .vimrc of course :)
Benoit
No `.vimrc` comes first :( and I really hate to modify plugins...
kfl62
Good to know about `:scriptnames` :) Thanks
kfl62
+3  A: 

Create the file ~/.vim/ftplugin/nerdtree.vim with the following contents, then you will not have to edit NERDTree itself:

if exists('b:haveRemappedT')
    finish
endif
let b:haveRemappedT=1
let s:oldmap=maparg('T', 'n')
function! s:LastTab()
    let tab=tabpagenr()
    tabnext
    execute "tabmove ".tabpagenr('$')
    execute "tabn ".tab
endfunction
execute 'nnoremap <buffer> T '.s:oldmap.':call <SID>LastTab()<CR>'
ZyX
Thanks, it's working :)
kfl62