5

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

  • With a fresh .vimrc
  • After deleting current MacVim install and downloading a fresh copy
  • In iTerm using 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.

muru
  • 4,723
  • 1
  • 34
  • 78
Josh Whittington
  • 705
  • 3
  • 10
  • 23
  • :set hls turns on search highlighting... am I misunderstanding your question? – Andy Ray Feb 25 '13 at 03:12
  • @AndyRay Nope - but you did, in one short sentence, help me understand that I'm improperly clearing the last search by using `noh` - that doesn't clear the search, it simply turns off `hlsearch`; when I source my vimrc, it's re-enabling highlighting. Thanks! – Josh Whittington Feb 25 '13 at 03:26

2 Answers2

3

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

Community
  • 1
  • 1
Josh Whittington
  • 705
  • 3
  • 10
  • 23
1

Going off what Josh was getting at. Add the following to your ~./vimrc:

" higlight search but not when sourcing .vimrc
set hls
let @/ = ""
mbigras
  • 7,664
  • 11
  • 50
  • 111