How to highlight search words in vim permanently?
For those wanting to visually keep highlighted their search:
:syn match stupid "
ctrl + /"
:hi stupid ctermbg=Red guibg=Red
Explanation:
The first line add your regex to a syntax type called "stupid" (note that ctrl + / means you must press ctrl+R then / to get the content of the search registry).
The second line gives a red color to the "stupid" syntax regex.
If you want to highlight multiple searches (in parallel, with different colors), check out my Mark plugin; it also allows to persist the highlightings across Vim sessions through the viminfo file; cp. :help mark-persistence
.
Set the command in .vimrc.
Use the following commands:
- Open
~/.vimrc
file (or create it if it didn't exist). - Add
set hlsearch
in the file. - Save the file.
Now your search will always be highlighted in vim.
For single time use, just use :set hlsearch
in vim, which will be in effect for that instance only.