RE: [PATCH] new flags for the search() function
> From: Benji Fisher [mailto:benji@...]...
> > >You are doing all right, 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
> My current suggestion includes a shorter, lessYes, little harder to read, though not impossible, perhaps a few
> 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.
more simple(r) examples to go with it?
> I have updated the patch to add Yet Another Flag: 'c' tells theI can't think at this minute when would I need to use it, however,
> 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 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?
> -----Original Message-----Hmmm, we agree (see my previous email) :-)
> 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.
> > I have updated the patch to add Yet Another Flag: 'c'Agreed again (see my previous email), what a day! :-):-)
> 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
> :let [lnum, col] = search???()