On 09/03/09 15:16, Ben Kim wrote:
>
> On Fri, 6 Mar 2009, Tony Mechelynck wrote:
>> However, Vim 7 includes the power of grep without the need for an
>> external program, and with Vim-specific "goodies" such as the
>> possibility of recursive search of directories, and the use of Vim-like
>> regular expressions:
>>
>> see
>>      :help :vimgrep
>>      :help new-vimgrep
>>
> :>  Since (IIUC) ":vimgrep" loads all the files it searches just like any
>> editfile, if your files can be opened correctly by means of your current
>> 'encoding' and 'fileencodings' settings, then :vimgrep will find any
>> occurrences in them of the Vim-like pattern you give it as an operand.
>> In particular, searching UTF-16 files with BOM should succeed if your
>> 'encoding' is set to UTF-8 and your 'fileencodings' start with
>> "ucs-bom". (If your files don't have a BOM then it's more ticklish.)
>
> Thanks. I could not figure out how to navigate through the results. I
> just started vim without opening files, and did something like
>
>       :vimgrep /\cstandard/ n*
>
> Vim opens only the first file. I'll have to read the help again.
[...]

This will create a quickfix list with all lines containing "standard", 
not necessarily as a separate word, and in any mix of upper- and 
lower-case, in any files whose names start with n in the current 
directory. The first match is displayed.

To go from match to match, use one or more of

        :cnext
        :cprev
        :cfirst
        :clast

which can of course be mapped for ease of use, e.g.

        :map  <F2>    :cnext<CR>
        :map  <S-F2>  :cprev<CR>

To see one line per match as a quickfix list, use

        :copen

then hitting <Enter> with the cursor on a match will display that match 
in the file where it is found.

To find all matches, but only as separate words, in (lets say) any HTML 
or XHTML files in the current directory or at any depth below it, you 
can use

        :vimgrep /\c\<standard\>/g ./**/*.htm ./**/*.html ./**/*.xhtml

see
        :help ordinary-atom
        :help starstar
        :help quickfix.txt


Best regards,
Tony.
-- 
How long a minute is depends on which side of the bathroom door you're
on.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to