for example suppose I did

:let foo=pattern

and now I want to perform Ggrep patter but use variable foo instead of the literal patter string.

:echo foo

outputs pattern, but

:Ggrep foo

just looks for foo

UPDATE:

building a string of command and then running :execute on it is not a solution, its a hack. And it breaks with any non-trivial variable values.

link|improve this question

80% accept rate
what is Ggrep (capital G?)? – akira Aug 8 '11 at 11:30
git grep from 'fugutive' vim plugin – Vitaly Kushner Aug 9 '11 at 10:08
feedback

1 Answer

what about:

:execute ':grep ' . foo
link|improve this answer
how do I properly escape foo's content? it might contain special characters like ", ', /, \, etc – Vitaly Kushner Aug 8 '11 at 11:34
1  
@Vitaly Kushner: See ":help escape()" and ":help fnameescape()". – garyjohn Aug 8 '11 at 16:45
I know escape(), but not sure about what characters to escape – Vitaly Kushner Aug 10 '11 at 13:00
fnameescape() is not good, its not a filename argument, its an arg to plugin function. suppose I :let foo = "aaa\"bbbb'cccc" – Vitaly Kushner Aug 10 '11 at 13:02
i think that 'how to escape a regular expression bullet-proof in vim' is another question, either here or on stackoverflow.com. – akira Aug 10 '11 at 17:52
show 7 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.