Ben Fritz <[email protected]> a écrit:
> On Wednesday, December 11, 2013 10:45:12 AM UTC-6, Paul Isambert wrote:
> >
> > > It looks like your complicated script just acts on the last search
> >
> > > match, just like gn does built-in.
> >
> >
> >
> > Actually it's a bit smarter, in that it also selects the IP address you're
> > on
> >
> > (with the cursor); the idea is that you probably want to select what your
> >
> > cursor is closer to. Of course that's just a matter of how the OP really
> >
> > works, but I thought an alternative solution sometimes helps, and a little
> >
> > complicated script can be really time-saving.
> >
> >
>
> I see, that's kind of clever. You'd need a workaround like pressing 0 first
> for gn to work. I wonder if gn could be made smart enough to just work if the
> cursor is currently on the match but not at the first character?
You still have the problem that / always match after the cursor
(unless, of course, you explicitly use something like “\%#” in the
regexp, but that’s quite impractical).
> > Plus you simply need "dI", "yI", etc.
> >
>
> You can also just use dgn, ygn, etc. One extra character, without a shift
> key...same basic effort.
Oh, I didn’t know “gn” what that clever. I’ve discovered it myself
last week or so, and haven’t had time to really use it.
... a few seconds later ...
Trying it right now: actually it does select the match if the cursor
is on it, the next match otherwise. So you can map something like:
/<regexp><CR>``gn
which will select the match the cursor is on, if any. And you could
also add a bit of “:nohl” to make things cleaner.
Best,
Paul
--
--
You received this message from the "vim_use" 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
---
You received this message because you are subscribed to the Google Groups
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.