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

RE: [PATCH] new flags for the search() function

Expand Messages
  • Zdenek Sekera
    ... You are doing all right, Benji! ... Yes, little harder to read, though not impossible, perhaps a few more simple(r) examples to go with it? ... I can t
    Message 1 of 13 , Dec 1, 2005
    • 0 Attachment
      > From: Benji Fisher [mailto:benji@...]
      ...
      > > >
      > > > How about an even longer paragraph that illustrates
      > most of the
      > > > flags? (Bram, if you like this explanation and it will
      > save you some
      > > > effort, I can make an updated patch.)
      > >
      > > I find the example a bit long, takes a bit of reading to understand.
      > > And it looks like the action can be done with one command
      > > ":%s/foo/bar/ge". Am I missing something? I'm sure it is
      > possible to
      > > come up with a shorter example that shows the use of the flags.
      >
      > I may not be able to satisfy both of you when it comes to
      > documentation!

      You are doing all right, Benji!

      > My current suggestion includes a shorter, less
      > comprehensive, more interesting example:
      >
      > Example of flags. >
      > :echo search('\<if\|\(else\)\|\(endif\)', 'nape')
      > < will search for the keywords "if", "else", and
      > "endif" under
      > or after the cursor. Because of the 'p' flag,
      > it returns 1,
      > 2, or 3 depending on which keyword is found, or 0 if the
      > search fails. Without the 'a' and 'e' flags,
      > this will not
      > find a keyword at the current cursor position;
      > with the 'a'
      > flag but not the 'e' flag, it will not find the
      > keyword under
      > the cursor if the cursor is in the middle or
      > end of the word.
      > The 'n' flag tells the function not to move the cursor.
      >

      Yes, little harder to read, though not impossible, perhaps a few
      more simple(r) examples to go with it?

      > I have updated the patch to add Yet Another Flag: 'c' tells the
      > function (search() or searchpair()) to return the column number of the
      > match instead of the line number. (Give an error message if combined
      > with 'p' or 'm'.)
      >

      I can't think at this minute when would I need to use it, however,
      I would imagine that knowing both *line* and *column* of the match
      should be *very* useful. I know it's not obvious to return two values,
      perhaps 'line:column' format or similar?

      Cheers,

      ---Zdenek
    • Zdenek Sekera
      ... Hmmm, we agree (see my previous email) :-) ... Agreed again (see my previous email), what a day! :-):-)
      Message 2 of 13 , Dec 1, 2005
      • 0 Attachment
        > -----Original Message-----
        > From: Bram@... [mailto:Bram@...]
        > Sent: 30 November 2005 20:30
        > To: Benji Fisher
        > Cc: vim-dev@...
        > Subject: Re: [PATCH] new flags for the search() function
        >
        >
        > Benji Fisher wrote:
        >
        > > I may not be able to satisfy both of you when it comes to
        > > documentation! My current suggestion includes a shorter, less
        > > comprehensive, more interesting example:
        >
        > The example looks fine to me. But I'm not sure if the explanation is
        > clear, e.g., what "keyword at the current cursor position" means
        > exactly. Perhaps a few snippets of example text will help.
        >

        Hmmm, we agree (see my previous email) :-)

        > > I have updated the patch to add Yet Another Flag: 'c'
        > tells the
        > > function (search() or searchpair()) to return the column
        > number of the
        > > match instead of the line number. (Give an error message
        > if combined
        > > with 'p' or 'm'.)
        >
        > Alternative: add a new function that returns a list with both the line
        > and column number. Otherwise you would need to search twice to get
        > both.
        >
        > :let [lnum, col] = search???()
        >

        Agreed again (see my previous email), what a day! :-):-)

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