Currently my /etc/vimrc file is set to the following: (
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
filetype plugin on if &term=="xterm" set t_Co=8 set t_Sb=^[[4%dm set t_Sf=^[[3%dm endifMy problem is that whenever I am in VIM and search for a string when it finds it it highlights it in a bright yellow block. This not not a problem unless I try to find text that is white, then it makes it very difficult to see. I have tried changing the line:
set hlsearch="another_color"But I get an error when trying open back up the file after saving.
Error detected while processing /etc/vimrc:
line 51:
E474: Invalid argument: hlsearch=lightIn this block of code something tells me this controls background and foreground colors, but I am not sure if that pertains to the "hlsearch" option.
if &term=="xterm" set t_Co=8 set t_Sb=^[[5%dm set t_Sf=^[[6%dm
endifI have tried changing the 5 and 6 to different numbers and that has no effect. I still have a yellow highlight box for searched text.
So my questions are:
1) Where is this "default" yellow color coming from?
2) How do I change it to something else?
2 Answers
All syntax colors, including the search highlight color, are set by changing a highlight group rather than an option. You set these groups with the :highlight command. For example I have changed search highlighting from yellow a bright turquoise:
:highlight Search guibg=Turquoise4I have also changed the IncSearch color, which is the color when 'incsearch' is set:
:highlight IncSearch gui=underline,bold guifg=White guibg=Red3See :help :highlight and :help highlight-groups.
Figured it out. In /etc/vimrc under the "syntax on" line add:
hi Search ctermbg=red
hi Search ctermfg=whiteThis example will give you a red block with white text while searching files with VIM. Inside VIM you can also do:
:highlight Search ctermfg=yellow To change it on the fly.