简体   繁体   English

Vim:采购vimrc时,重新出现上一次搜索hl

[英]Vim: When sourcing vimrc, last search hl re-appears

The title pretty much says it all. 标题基本概括了所有内容。 When I :source $MYVIMRC or :source ~/.vimrc , the last search re-appears. 当我:source $MYVIMRC:source ~/.vimrc :source $MYVIMRC :source ~/.vimrc ,重新出现最后一个搜索。 I can easily turn this off again with :noh , but it re-appears every time I :source . 我可以使用:noh轻松地再次关闭它,但是每次我:source时它都会重新出现。

This persists 这仍然存在

  • With a fresh .vimrc 用新鲜的.vimrc
  • After deleting current MacVim install and downloading a fresh copy 删除当前的MacVim安装并下载新副本后
  • In iTerm using vim 在iTerm中使用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: 我已经检入了:version列出的每个文件,除了.vimrc ,列出的唯一另一个不为空的文件是$VIM/vimrc仅具有:

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 @/ = "" . 归功于@AndyRay-我误用了noh来摆脱上一次搜索的突出显示,而我应该使用:let @/ = ""覆盖搜索项。

See: Vim clear last search highlighting 请参阅: Vim清除上一次搜索突出显示

Going off what Josh was getting at. 摆脱Josh的想法。 Add the following to your ~./vimrc : 将以下内容添加到~./vimrc

" higlight search but not when sourcing .vimrc
set hls
let @/ = ""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM