tags:

views:

90

answers:

1

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!

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

:MyFunc /Hello world/
Mykola Golubyev
Why is this -nargs=1 and not -nargs=+ ?
anon
Because you need only one argument and it is a regexp.
Mykola Golubyev