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

Re: vim6: "fuzzy" regexp match, howto?

Expand Messages
  • Zdenek Sekera
    ... This is briliant! Thanks!
    Message 1 of 4 , Nov 2 6:34 AM
      c928400@... wrote:
      >
      > Thus wrote Zdenek Sekera (zs@...) on [001102]:
      > > I have a regexp (may be a multiline and lots of times it is) and I need
      > > to
      > > find the starting point in the file where that regexp matches.
      > > That simple enough, however, I need to find it subject to the following
      > > condition: the cursor can be at the time of match anywhere in the file
      > > and I need to establish if the string matching the regexp can be found
      > > such that the cursor is *inside* the matched string (including first and
      > > last char of the matched string). And if so return the line and the
      > > starting
      > > char position of the matched string.
      >
      > How about the functions below?
      >
      > The following command
      >
      > :echo StartOffPatWithCurPos(pattern)
      >
      > will simply echo a string of "line col virtual-col" of the start of
      > the match that contains current position - if any.
      >


      This is briliant! Thanks!

      ---Zdenek
    • c928400@student.dtu.dk
      ... OK, Zdenek and I had a little talk, and I came up with the attached script. The aim of the main function is to locate a pattern that includes the current
      Message 2 of 4 , Nov 8 6:50 AM
        Thus wrote Peppe paa DTU (c928400@...) on [001102]:
        > Thus wrote Zdenek Sekera (zs@...) on [001102]:
        > > I have a regexp (may be a multiline and lots of times it is) and I need
        > > to
        > > find the starting point in the file where that regexp matches.
        > > That simple enough, however, I need to find it subject to the following
        > > condition: the cursor can be at the time of match anywhere in the file
        > > and I need to establish if the string matching the regexp can be found
        > > such that the cursor is *inside* the matched string (including first and
        > > last char of the matched string). And if so return the line and the
        > > starting
        > > char position of the matched string.

        > How about the functions below?

        OK, Zdenek and I had a little talk, and I came up with the attached
        script.

        The aim of the main function is to locate a pattern that includes the
        current position and return information about the pattern and/or
        current position.

        This may sound as a strange thing to do, but see the documentation for
        an example with HTML.


        Btw, I like the idea of eg "dvj", where one uses v, V, or <C-V> to
        alter the behaviour of the motion afterwards. But it appears that no
        vmap's are carried out for this visual-like selection. Is there a way
        around this, or is it intended behaviour? (omaps does not seem to do
        the trick :-( ).

        Peppe
      Your message has been successfully submitted and would be delivered to recipients shortly.