command Gr execute 'vimgrep /'.@/.'/g %'
John
Method I.
Don't write any user-command. Just hit Ctrl-R followed by / between the
two slashes delimiting your vimgrep pattern.
See "help c_CTRL-R"
Method II.
command -bar -nargs=+ -complete=file
\ Gr exec 'vimgrep /' . @/ . '/g' <q-args>
then ":Gr %" will search the current file, and ":Gr *.[ch]" will search
*.c and *.h files, etc.
The idea is that @/ (when used to mean the latest search pattern) is a
variable name, not a string value.
See
:help :command
:help :execute
:help expression-syntax
then scroll down a page or so
until you see the various kinds of |expr9|
Best regards,
Tony.
--
The ladies men admire, I've heard,
Would shudder at a wicked word.
Their candle gives a single light;
They'd rather stay at home at night.
They do not keep awake till three,
Nor read erotic poetry.
They never sanction the impure,
Nor recognize an overture.
They shrink from powders and from paints ...
So far, I've had no complaints.
-- Dorothy Parker