Reputation: 42587
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 this?
Thanks!
Upvotes: 5
Views: 844
Reputation: 1312
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/.
Upvotes: 0
Reputation: 59804
:command -nargs=1 MyFunc vimgrep <args> **/*.cpp **/*.hpp
:MyFunc /Hello world/
Upvotes: 5