简体   繁体   English

NERDTree在新标签中打开,作为gvim中的最后一个标签?

[英]NERDTree open in a new tab, as last tab in gvim?

In NERDTree Shift T opens file in a new tab, but tab is positioned after the tab in which NERDTree is opened. 在NERDTree Shift T中,在新选项卡中打开文件,但选项卡位于打开NERDTree的选项卡之后。

It is possible 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: 使用以下内容创建~/.vim/ftplugin/nerdtree.vim文件,然后您不必编辑NERDTree本身:

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. 这是一个通用的autocmd,用于在最后打开所有新选项卡。 It works with NERDTree too. 它也适用于NERDTree。

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

Add the following to your .vimrc 将以下内容添加到.vimrc中

autocmd BufNew * execute ":tabmove99"

This will always position newly open tabs at location 99 to the right. 这将始终将新打开的标签放置在右侧的位置99。

我建议你编辑插件并将其重新映射到:tablast before :tabnew

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM