On Dec 2, 7:26 pm, "John Beckett" <[EMAIL PROTECTED]> wrote:
> I checked to see if this needed to be added to the wiki, and found that it is
> covered in tip 1543 (with a command rather than a
> mapping):http://vim.wikia.com/wiki/Find_in_files_within_Vim
>
> command GREP :execute 'vimgrep /'.expand('<cword>').'/gj '.expand('%') | copen
>
> Can anyone tell me if there is a reason to use "expand('%')" in the above?
> What
> about:
>
> command GREP2 :execute 'vimgrep /'.expand('<cword>').'/gj %' | copen
>
Possible bonus of expand: you can search again in the same file if
using the command history, even if you are in a different buffer. This
would be even better if expand("%:p") were used instead, since options
like autochdir or commands that change the directory would interfere.
Just using '%' by itself would always search the current buffer, which
would also be useful. Because this is a "search current buffer only"
command, I think that not having the expand() would make more sense.
Note that for this method of searching a buffer to work, the buffer
must be as it appears on the disk.
Personally, I use the cabbrev from the same tip mentioned above, so
that I have a chance to tweak the command before running the search.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---