Tuesday, July 19, 2011

Re: Visually select current match

Thank you very much!

> :nmap ,n /<C-R>//b<CR>ma/<C-R>//e<CR>mb`av`b

Would you mind confirming my understanding is correct:

/<C-R>//b<CR> - / and inserts the last search (<C-r>/) pattern then
appends /b so that it stops at the beginning of the match
ma - sets marker a (at the beginning of the match)
/<C-R>//e<CR> - same as above but moves to the end of the match;
because it starts at the current position, it doesn't go to the next
match in the file.
mb - sets marker b
`a - jumps back to marker a
v - switches to visual mode
`b - jumps (and selects) to marker b

Did I get it right?

Thanks again.


On Jul 19, 1:34 am, Warwick Allen <warw...@datumprocess.co.nz> wrote:
> :nmap ,n /<C-R>//b<CR>ma/<C-R>//e<CR>mb`av`b
> :vmap ,n <ESC>/<C-R>//b<CR>ma/<C-R>//e<CR>mb`av`b
>
> (using ,n instead of clobbering n)
>
> On Jul 19, 5:53 pm, Gary Johnson <garyj...@spocom.com> wrote:
>
>
>
>
>
>
>
> > On 2011-07-18, philipx wrote:
> > > Is there a way to have vim visually select (not just hlsearch) the
> > > current match?
>
> > > That is every time I press "n" or "N" while performing a search I'd
> > > like vim to automatically visually select the match so that I can
> > > immediately perform operations on the match.
>
> >     v//e
>
> > That has the side-effect of changing the current search pattern to
> > include the e flag, so if you want to repeat the search, you may
> > have to recall the original pattern from search history.
>
> > There might also be a better solution to the actual problem you're
> > trying to solve, but it's hard to know without more information
> > about the problem.
>
> > Regards,
> > Gary

--
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

No comments:

Post a Comment