vim – 重映射NERDTree双击“T”

使用VIM NERDTree插件.

是否有任何方法重新映射双击文件操作以在新选项卡(T)中静默打开文件?

1介绍

这适用于NERD树版本4.2.0.

2在新选项卡中打开目录和文件

如果要在新选项卡中打开目录和文件,只需将以下行添加到〜/ .vimrc.

let g:NERDTreeMapOpenInTabSilent = '<2-LeftMouse>'

3仅在新选项卡中打开文件

如果您只想在新标签页中打开文件,则必须执行更复杂的操作.

将此函数添加到NERD_tree.vim中的某个位置:

" opens a file in a new tab
" KeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
" stayCurrentTab: if 1 then vim will stay in the current tab,if 0 then vim
" will go to the tab where the new file is opened
function! s:openInTabAndCurrent(keepWindowOpen,stayCurrentTab)
    if getline(".") ==# s:tree_up_dir_line
        return s:upDir(0)
    endif

    let currentNode = s:TreeFileNode.GetSelected()
    if currentNode != {}
        let startToCur = strpart(getline(line(".")),col("."))

        if currentNode.path.isDirectory
            call currentNode.activate(a:keepWindowOpen)
            return
        else
            call s:openInNewTab(a:stayCurrentTab)
            return
        endif
    endif
endfunction

并更换线

nnoremap <silent> <buffer> <2-leftmouse> :call <SID>activateNode(0)<cr>

有:

nnoremap <silent> <buffer> <2-leftmouse> :call <SID>openInTabAndCurrent(0,1)<cr>

您可以在文件NERD_tree.vim中的函数s:bindMappings()中找到此行.

相关文章

解决方案:解决linux下vim乱码的情况:(修改vimrc的内容)全...
Linuxvi/vim所有的UnixLike系统都会内建vi文书编辑器,其他的...
      vim正则匹配:空行:/^$/  /^[\t]*$/注释...
$select-editorSelectaneditor.Tochangelater,run'sele...
上次手贱忘了保存,这次就简单做个备忘吧,把踩过的坑记一下...
Linux之文本编译器小结vim的优势所有的UNIX-LIKE习通都会内置...