微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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()中找到此行.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐