开发者

How do I write a vim function that calls VimGrep?

I want to write a function myFunc such that:

myFunc /function foo/

becomes

:vimgrep /function foo/ **/*.cpp **/*.hpp

and

myFunc /class bar: public/

becomes

vimgrep /class bar: public/ **/*.cpp **/*.hpp

how do I do 开发者_如何学Gothis?

Thanks!


:command -nargs=1 MyFunc vimgrep <args> **/*.cpp **/*.hpp

:MyFunc /Hello world/


You might want to checkout a plugin I wrote called EasyGrep. It has builtin support for this when you use tracked mode. What you can do is place your cursor over a word (or visually select some text) and type <leader>vv and it will search all of *.cpp *.hpp *.cxx *.hxx *.cc *.c *.h for the pattern. Once you get used to typing <leader>vv it is significantly faster than typing :Command /Pattern/.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜