Vim: When sourcing vimrc, last search hl re
The title pretty much says it all. When I :source $MYVIMRC
or :source ~/.vimrc
, the last search re-appears. I can easily turn this off again with :noh
, but it re-appears every time I :source
.
This persists
.vimrc
vim
I have checked in every file listed with :version
, and other than my .vimrc
, the only other file listed that isn't empty is $VIM/vimrc
- which has only:
set nocompatible
set backspace+=indent,eol,start
set langmenu=none
I also tried the nuclear method: disable all plugins and pretend it's a fresh install:
mv .vim .vim-old
mv .vimrc .vimrc-old
touch .vimrc
echo "set hlsearch" > .vimrc
The issue still occurs.
I'm pretty stumped as I don't recall this being the normal behavior; any help would be much appreciated.
Credit to @AndyRay - I was misusing noh
to get rid of the last search's highlighting, when instead I should be overriding the search term with :let @/ = ""
.
See: Vim clear last search highlighting
Going off what Josh was getting at. Add the following to your ~./vimrc
:
" higlight search but not when sourcing .vimrc
set hls
let @/ = ""
链接地址: http://www.djcxy.com/p/49386.html