vim:为grep+;科本+;增量搜索
我想定义一个自定义命令来执行以下步骤:grep当前单词,copen,增量搜索grep'ed单词。下面是我正在使用的命令: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// 但
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
- 这是由以下插件解决的类似问题:,和
:让单词=展开(“”|…