Loading ...
Sorry, an error occurred while loading the content.

50056Re: regex: multiline search limited to blocks

Expand Messages
  • Benji Fisher
    May 11, 2004
    • 0 Attachment
      On Mon, May 10, 2004 at 05:49:10PM -0700, Hari Krishna Dara wrote:
      > Can anyone please confirm that this is a bug in Vim? Will there be a
      > fix?
      >
      > Thank you,
      > Hari
      >
      [snip]
      > > /insert\(\_.\(\_^\s*\_$\)\@!\)\+TOTABLE\(\_.\(\_^\s*\_$\)\@!\)\+from
      > >
      > > This would match something like:
      > >
      > > insert into TOTABLE (
      > > FIELD1,
      > > FIELD2,
      > > FIELD3,
      > > FIELD4)
      > > select
      > > val1,
      > > val2,
      > > val3,
      > > val4
      > > from
      > > FROMTABLE
      > >
      > > However, when I used the above regex, Vim had trouble searching for all
      > > the matches, sequentially. I first composed the regex to match the
      > > statement that I was interested in, then wanted to find all the
      > > statements that are similar in the same file. So I went to the start and
      > > started executing "n" command to see the matches one after the other,
      > > but figured it never matched the original statement. When I manually
      > > moved the cursor a couple of lines before the original statement and
      > > executed "n", it nicely matched, suggesting an issue with the distance
      > > from the cursor position.
      > >
      > > I did a little more research by using search() function instead of /
      > > command with the same regex. It behaved exactly the same, except that
      > > this time, I got the following error message instead of just keeping
      > > quite when there are no matches found.
      > >
      > > E363: pattern caused out-of-stack error
      > >
      > > Any idea if this is a problem with the regex that I used or a bug in
      > > Vim?
      > >
      > > Thank you,
      > > Hari

      I tried the regex you mentioned. Just to be sure, here it is
      again:
      insert\(\_.\(\_^\s*\_$\)\@!\)\+TOTABLE\(\_.\(\_^\s*\_$\)\@!\)\+from
      I copied your snippet to a new buffer, removed the mail quotes ("> > "),
      and made a few copies, separated by blank lines. When I searched for
      the pattern, I found all the copies, including the one that began on
      Line 1. This is with vim 6.3a. Can you give a simple example of a file
      where there is a problem?

      I also had no trouble with using search(), but I am not all that
      surprised that you got an out-of-stack error with a real-life example.
      That '\_.' followed by '\(...\)\@!', all enclosed in '\(...\)\+' is one
      mean pattern! Maybe there is a way to do what you want without using a
      single regex...

      HTH --Benji Fisher
    • Show all 6 messages in this topic