Thursday, April 5, 2012

Re: vimgrep

On Wednesday, April 4, 2012 1:27:21 PM UTC-5, hilal Adam wrote:
> Ben, Thanks for your prompt response.
> Somehow I am getting 3 copies of your premature, and complete replies.
>

I only see one post. Weird. I'm starting to really hate the Google
Groups interface. I may try subscribing to get emails and just filter
them all away from my inbox. Ugh.

Maybe you're getting multiple copies because you're on the CC list as
well as subscribed to the mailing list? I've never had problems with
that, but I've been using the web interface for quite some time now
without getting any email I don't subscribe to directly.

> Yes. You're right \*\* was one of the approaches I used.
> Unfortunately * is treated as a metacharacter/special character/keyword
> by grep/vimgrep/c language and this where the difficulty is originating
> from.
>

* is not special anymore if escaped with a \.

> I tried your suggestion, \*\@<!\*\*\*\@!, and I get a no pattern
> found reply while I stirring at a line that has **.
>
> How would you do this in grep on cygwin command line?
>

I don't know about using grep from the cygwin command line. The pattern
I gave uses Vim regular expressions, so you'd need to use a :vimgrep
command to use it.

Here's the breakdown:

\*\@<! - match only where there is not a literal '*' just before
\*\* - two literal '*' characters
\*\@! - match only where there is not a literal '*' as the next
character after the match

These are both zero-width matches, meaning they are not part of the
match itself. I don't think grep from the cygwin command line supports
any such concept.

Someone else (Google Groups mangled the non-ascii characers in the name)
suggested \zs and \ze which similarly won't be supported. But if you are
using an external grep command this probably won't matter, since you can
accept matches of the character (or beginning/end of line) immediately
before/after the **. The suggested \(^\|[^*]\)\*\*\([^*]\|$\) pattern
may work in grep, possibly with some tweaking for syntax.

--
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

No comments: