vimvimgrep

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 this?

Thanks!


Solution

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