Tuesday, November 26, 2013

Re: Search and stay

On 11/25/2013 06:22 AM, Paul Isambert wrote:
> "Paolo Bolzoni" <paolo.bolzoni.brown@gmail.com>:
>> I often search text in the latex documents to move around.
>> So I press /<some known sentence> and Vim shows me the
>> place because I have incsearch active.
>>
>> Can I just stay in the place without pressing enter?
>> I am asking because I also have hlsearch on and while
>> it is normally useful in this particular case is not.
>
> I've been wishing that could be done for some time now, but you can't;
> however, you can use a mapping like:
>
> cnoremap <C-Enter> <Enter>:nohls<CR>
>
> which does what you want with <Ctrl-Enter>; note that when used in the
> command-line while not searching it will remove the previously highlighted
> search, if any.

I have a similar mapping for this. I override the functionality
of CTRL-L to have it :nohlsearch in addition to redrawing the
screen:

nnoremap <silent> <C-L> :nohlsearch<CR><C-L>

This avoids consuming an extra mapping key. The added
functionality seems to fit well with my intuition of CTRL-L's
intended purpose, which makes the key easy to remember as well.
It costs an extra keypress to turn off the highlighting in your
use case, but I find that my most common use is to perform a
search where I'm interested in the highlighting, then to turn
off the distraction of highlighting once I'm done. It then
becomes natural to turn off highlighting immediately for the
more rare case where I didn't want it on in the first place.

Michael Henry

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment