How to write a vim function that calls VimGrep?

I want to write myFunc function to:

myFunc /function foo/ 

becomes

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

and

 myFunc /class bar: public/ 

becomes

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

how to do it?

Thanks!

+4
source share
2 answers
 :command -nargs=1 MyFunc vimgrep <args> **/*.cpp **/*.hpp :MyFunc /Hello world/ 
+4
source

You might want to check out the plugin I wrote called EasyGrep . It supports native support when using tracked mode. What you can do is place the cursor over the word (or visually select some text) and type <leader> vv, and it will look for everything * .cpp * .hpp * .cxx * .hxx * .cc * .c * .h for drawing. When you get used to the <leader> vv set, this is significantly faster than typing: Command / Pattern /.

0
source

Source: https://habr.com/ru/post/1300155/


All Articles