On Wednesday, April 4, 2012 12:22:19 PM UTC-5, Ben Fritz wrote:
> On Wednesday, April 4, 2012 12:12:28 PM UTC-5, hilal Adam wrote:
> > Sorry if not correct platform for this question.</div>
> > Need to use vimgrep/grep to find a particular string in c code.  I am 
> > trying to find all occurrences of &#39;**&#39; (pointer to pointer). But I 
> > get hundreds of lines of output for all comment lines which include a 
> > minimum of 2 &#39;*&#39;s.</div>
> > Any help is appreciated.</div>
> > 
> > </div>
> > HA
> > </div></div></div>
> 
> vimgrep, just like '/' searching in Vim, uses regular expressions. In a 
> regular expression, * means "as many as possible of the preceding search 
> atom" which normally means "as many as possible of the preceding character".
> 
> You don'

Dammit, I accidentally hit some key combination which Google Groups used to 
post before I was done.

You don't give the exact search you used, so I was guessing here that you 
searched with ** as your search pattern, which will match zero or more '*' 
characters, but I realize now that this will match absolutely anything, because 
"as many as possible" means zero or more, so ** will match every line in every 
file.

Probably, then, you searched for \*\*, which will match 2 '*' characters in a 
row. However, it will match ANY two * characters, even if followed by another 
character which is not a * character.

You need to specify that you only want to match where the preceding character 
and the next character are not also *.

To do this, I'd use a pattern like:

\*\@<!\*\*\*\@!

or simpler, with "very not magic":

\V*\@<!***\@!

See :help /\@<! and :help /\@!

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to