Well, I try to use the following convention. ± (as unused key) is used for increase search where / is used for regular search.

The implementation:

set noincsearch

nmap  ± <esc>:set incsearch<CR>/

augroup vimrc-noincsearch-highlight
  autocmd!
  autocmd CmdlineLeave / :set noincsearch |  :noh 
augroup END

Everything works fine.

The only tiny problem is that I get a beep every time I use it!

I tried to use other keys as well, but I get the same anonying beep.

Temporary solution:

set visualbell t_vb=

Help?

Thanks.

  • 2
    The beep is probably from <esc>; does it work if you remove that and use nnoremap ? – D. Ben Knoble Oct 26 at 3:07
  • Yes. It does. Thanks. – eyal karni Oct 26 at 22:57
  • Will post answer later – D. Ben Knoble Oct 26 at 23:59
up vote 2 down vote accepted
nmap  ± <esc>:set incsearch<CR>/

<Esc> in normal mode issues a beep. Your :nmap is a normal mode mapping; no <esc> is necessary here. You could use <C-u> to swallow any accidental [count], though. And you should use :noremap; it makes the mapping immune to remapping and recursion:

nnoremap  ± :<C-u>set incsearch<CR>/

Though not needed here, there is a special mapping that ensures normal mode without a beep: :help CTRL-\_CTRL-N

Additionally the command CTRL-\ CTRL-N or can be used to go to Normal mode from any other mode. This can be used to make sure Vim is in Normal mode, without causing a beep like would. However, this does not

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.