Reputation: 3040
I want to highlight the search keyword in Vim. Mainly I use vim to debug the logs.
I always have to use :se hlsearch
to highlight the search keyword.
So, I want the solution that it should set command permanently, and I should not use the command always when vim starts.
Upvotes: 74
Views: 92159
Reputation: 303
My SelX plugin allows you to highlight and search for many different things at once on a per-tab basis, with different colours. The highlight config can be saved to a vim session
https://www.vim.org/scripts/script.php?script_id=5875
Upvotes: 0
Reputation: 3040
Set the command in .vimrc.
Use the following commands:
~/.vimrc
file (or create it if it didn't exist).set hlsearch
in 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.
Upvotes: 125
Reputation: 4041
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.
Upvotes: 4
Reputation: 172570
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
.
Upvotes: 7