Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vim:为grep+;科本+;增量搜索_Vim_Grep_Incremental Search - Fatal编程技术网

vim:为grep+;科本+;增量搜索

vim:为grep+;科本+;增量搜索,vim,grep,incremental-search,Vim,Grep,Incremental Search,我想定义一个自定义命令来执行以下步骤:grep当前单词,copen,增量搜索grep'ed单词。下面是我正在使用的命令: nmap <C-p> :execute "grep! -Irn " . shellescape(expand("<cword>")) . " ."<cr>:copen<cr>:g/<cword>/<cr> nmap:执行“grep!-Irn”。shellescape(展开(“”)。“:科本:g// 但

我想定义一个自定义命令来执行以下步骤:grep当前单词,copen,增量搜索grep'ed单词。下面是我正在使用的命令:

nmap <C-p> :execute "grep! -Irn " . shellescape(expand("<cword>")) . " ."<cr>:copen<cr>:g/<cword>/<cr>
nmap:执行“grep!-Irn”。shellescape(展开(“”)。“:科本:g//

但是在快速修复窗口打开后,第二个cword将扩展到当前单词。我如何使用grep之前使用的单词?

与您将
导入
grep
的方式相同:

nmap <C-p> :execute "grep! -Irn " . shellescape(expand("<cword>")) . " .\<cr>:copen\<cr>:g/" . expand("<cword>"). "/\<cr>"<cr>
nmap:执行“grep!-Irn”。shellescape(展开(“”)。“\:范围\:g/”。展开(“”)。"/\"
一些想法:

  • 设置搜索寄存器,而不是
    :g
    。例如:
    :let@/=“foo”
  • 使用
    nnoremap
  • 使用
    escape()
    使其更具弹性。参见
    :h转义(
  • 可能使用
    :vimgrep
    。请参阅
    :h:vimg
  • 这是由以下插件解决的类似问题:,和

将单词存储到变量中,以后再使用。
:让单词=展开(“”|…