+ copy vim-dev
Christian Brabandt wrote:
> On Do, 19 Jul 2012, Bram Moolenaar wrote:
>
> > Aha. Well, what I think about the a/ object is that it's too different
> > from the other text objects. The existing ones select an object under
> > the cursor.
> >
> > I can understand that selecting a match with the search pattern is
> > useful. But that this happens somewhere away from the cursor position
> > is weird. "da/" may jump to the other side of the buffer and delete an
> > unknown amount of text there, the user may not expect that. Or expect
> > that the text from the cursor to and including the match is deleted.
> >
> > I think most users would see the match highlighting, and think there
> > would be a way to operate on the highlighted text. Perhaps something
> > similar to "gv" could be used: Visually select the next highlighted text
> > (which is the next match with the search pattern). We could use g/, but
> > unfortunately g? is already taken.
>
> How about using gn and gN (like using 'n' and 'N'), with the exception,
> that gn always moves to the next selection and gN moves to the previous
> match and when the cursor is already on a match, both select the same
> object?
>
> It's a lot simpler this way without messing with the text-object stuff,
> so here is a new version of the patch.
[...]
> + *gn* *v_gn*
> +gn Start Visual mode and select the next search match
> + from the last search pattern in forward direction.
> + If Visual mode is active, extends the selection
> + until the end of the next match.
> +
> + *gN* *v_gN*
> +gN Like |gn| but selects the previous match.
> +
That sounds good. I haven't tried the patch yet. Please also write a
test for this, then send the patch to the vim-dev list so that others
can try it out and comment.
Several users have asked about operating on the search match, I think
this is the simplest way that allows to do just about everything. The
only drawback would be that it uses Visual mode, thus when used in a
script or mapping it would have to save/restore Visual mode perhaps.
What I will probably use a lot is "gns" to substitute a match with other
text. Then use "n" and "." to repeat (when the size is fixed) or
"gns^@" (when the size changes).
--
hundred-and-one symptoms of being an internet addict:
160. You get in the elevator and double-click the button for the floor
you want.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php