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

Re: Calling Benji: matchit.vim question

Expand Messages
  • Benji Fisher
    ... This tells matchit.vim that declare and end form a matching pair, with begin and exception as significant intermediates. It is a lot like the
    Message 1 of 4 , Mar 1, 2002
    • 0 Attachment
      yahoogroups@... wrote:
      >
      > I am trying to configure matchit.vim for use with PL/SQL code. Here is what I
      > have so far in my sql.vim ftplugin
      >
      > let s:notend = '\%(\<end\s\+\)\@<!'
      > let b:match_words=''
      >
      > " DECLARE/BEGIN/EXCEPTION/END block
      > let b:match_words=b:match_words .
      > '\<declare\>:\<begin\>:\<exception\>:\<end\>\%(\s*\<if\>\)\@!'

      This tells matchit.vim that "declare" and "end" form a matching pair,
      with "begin" and "exception" as significant intermediates. It is a lot like
      the matching pair "while" and "endwhile" in vim, with intermediates "continue"
      and "break". So "declare...begin...exception...begin...end" is analogous to
      "while...continue...break...continue...endwhile".

      [snip]
      >
      > Note that the DECLARE is optional in every PL/SQL block.
      >
      > If I have a file like
      >
      > declare
      > ...
      > begin
      > ...
      > begin
      > exception
      > end
      >
      > select
      > into
      > from
      > where
      > end
      >
      > The problem is that with the cursor on the first declare, when I do %, I indeed
      > go to the first BEGIN, but then my next % goes to the next BEGIN instead of
      > going to the END on the last line.
      >
      > Am I doing something wrong?

      Yes. As far as matchit.vim is concerned, the structure is like this:

      declare
      ...
      begin
      ...
      begin
      exception
      end

      select
      into
      from
      where
      end

      with the final "end" unmatched. Keep hitting %, and you should go from the
      second "begin" to "exception", "end", and back to "declare".

      If the "declare" is optional, you should probably leave it off entirely.
      Each matching group should have a unique starting pattern and a unique closing
      pattern. There can be any number of intermediate patterns.


      > Benji? Help please?

      Do not think I am the only one who can answer this! I did not write many
      of the matching patterns that go with matchit.vim; I mostly think about the
      script itself.

      --Benji Fisher
    • yahoogroups@vikas.mailshell.com
      ... Hm. What about patterns common to 2 groups? If I have a group with start,middle1,middle2,end and another group with start2,middle3,middle2,end2 The
      Message 2 of 4 , Mar 2, 2002
      • 0 Attachment
        --- Benji Fisher <benji.at.e-math.AMS.org@...>
        wrote:
        > Each matching group should have a unique starting pattern and a unique
        > closing pattern. There can be any number of intermediate patterns.

        Hm. What about patterns common to 2 groups? If I have a group with
        start,middle1,middle2,end

        and another group with

        start2,middle3,middle2,end2

        The "middle2" is common to both the groups. This seems to be causing
        matchit.vim to get confused as to which group's patterns it is bouncing
        between.

        Almost seems as if all the patterns in all the groups have to be unique. Is
        this right?

        Thanks

        P.S: This is the same discussion as on the other mail I sent you, but it is
        more relevant here.


        __________________________________________________
        Do You Yahoo!?
        Yahoo! Sports - sign up for Fantasy Baseball
        http://sports.yahoo.com
      • Benji Fisher
        ... Yes, the patterns all have to be unique. If you hit % starting on middle2 , how is the script supposed to decide where to go next? I think the best
        Message 3 of 4 , Mar 4, 2002
        • 0 Attachment
          yahoogroups@... wrote:
          >
          > --- Benji Fisher <benji.at.e-math.AMS.org@...>
          > wrote:
          > > Each matching group should have a unique starting pattern and a unique
          > > closing pattern. There can be any number of intermediate patterns.
          >
          > Hm. What about patterns common to 2 groups? If I have a group with
          > start,middle1,middle2,end
          >
          > and another group with
          >
          > start2,middle3,middle2,end2
          >
          > The "middle2" is common to both the groups. This seems to be causing
          > matchit.vim to get confused as to which group's patterns it is bouncing
          > between.
          >
          > Almost seems as if all the patterns in all the groups have to be unique. Is
          > this right?
          >
          > Thanks

          Yes, the patterns all have to be unique. If you hit % starting on
          "middle2", how is the script supposed to decide where to go next? I think the
          best solution here is to use

          start\|start2:middle1:middle2:middle3:end\|end2

          I think we do something like that in HTML to handle <ul>:<li>:</ul> (unordered
          lists) and <ol>:<li>:</ol> (ordered lists).

          HTH --Benji Fisher
        Your message has been successfully submitted and would be delivered to recipients shortly.