【问题标题】:Prevent grep results opening in NerdTree window防止在 NerdTree 窗口中打开 grep 结果
【发布时间】:2015-11-12 10:02:12
【问题描述】:

我刚刚开始使用 EasyGrep 。当我进行搜索时,我的 NERDTree 窗口通常处于焦点位置,并且第一个搜索结果会加载到此窗口中。

有没有办法强制 EasyGrep 在主缓冲区窗口中打开第一个结果?

谢谢!

【问题讨论】:

  • Vim 有 no notion of project drawer,所以我怀疑是否有很多方法可以避免这种行为,而无需更改工作流程或向 EasyGrep 提交问题。

标签: search vim grep nerdtree


【解决方案1】:

这是我在.vimrc 中添加的内容:

function! SearchOutsideOfNerdtree()
  if &filetype == 'nerdtree'
    :wincmd l
  endif
  :execute input("", ":Grep\<Space>")
endfunction

function! ReplaceOutsideOfNerdtree()
  if &filetype == 'nerdtree'
    :wincmd l
  endif
  :execute input("", ":Replace\<Space>")
endfunction

nnoremap <Leader>f :call SearchOutsideOfNerdtree()<CR>
nnoremap <Leader>g :call ReplaceOutsideOfNerdtree()<CR>

基本上我创建了一个函数来检查当前文件类型是否为nerdtree,然后我移动到正确的缓冲区。

【讨论】:

    【解决方案2】:

    这是我在 .vimrc 中添加的内容,它可以工作:

    nnoremap <silent> ,g  :<C-u>wincmd w<CR>:Unite grep:. -buffer-name=search-buffer<CR>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-30
      相关资源
      最近更新 更多