> Hi everyone here, I'm just new to this mailing list.  I want to 
> automatically disable search highlight when entering insert mode, so I 
> add the command in ~/.vimrc but it didn't work. Does anyone know what 
> I did was wrong?
As pointed out, :noh[lsearch] doesn't work in autocmds.  One common 
workaround is to do it from a mapping.  I have the following in my 
~/.vimrc:
" turn off highlighting when refreshing the screen
nn <silent> <C-l> :noh<CR><C-l>
(nn = nnoremap)
Seems like overkill, but you could use:
for key in ['i','I','o','O','a','A','gi','gI'] " any key that enters insert mode
 	exe 'nn <silent>' key ':noh<CR>'.key
endfor
Personally, the <C-l> trick works well for me, because I'm used to 
typing Ctrl+l to refresh Alpine.
-- 
Best,
Ben H
-- 
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