开发者

NERDTree open in a new tab, as last tab in gvim?

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

It is possib开发者_C百科le to open the new tab at the end of tabs?


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>'


Here's a general purpose autocmd for opening all new tabs at the end. It works with NERDTree too.

" move tabs to the end for new, single buffers (exclude splits)
autocmd BufNew * if winnr('$') == 1 | tabmove99 | endif


Add the following to your .vimrc

autocmd BufNew * execute ":tabmove99"

This will always position newly open tabs at location 99 to the right.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜