加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim – 重映射NERDTree双击“T”

发布时间:2020-12-16 01:22:52 所属栏目:安全 来源:网络整理
导读:使用VIM NERDTree插件. 是否有任何方法重新映射双击文件操作以在新选项卡(T)中静默打开文件? 1介绍 这适用于NERD树版本4.2.0. 2在新选项卡中打开目录和文件 如果要在新选项卡中打开目录和文件,只需将以下行添加到?/ .vimrc. let g:NERDTreeMapOpenInTabSile
使用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()中找到此行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读