Search code examples
vim

How to highlight search words in vim permanently?


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.


Solution

  • Set the command in .vimrc.

    Use the following commands:

    1. Open ~/.vimrc file (or create it if it didn't exist).
    2. Add set hlsearch in the file.
    3. 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.