vimtricks.wiki Concise Vim tricks, one at a time.

How do I highlight the line the cursor is on?

Answer

:set cursorline

Explanation

The cursorline option highlights the entire line where the cursor is positioned. This makes it easier to see which line you are on.

How it works

  • :set cursorline enables the highlight
  • :set nocursorline disables it
  • The highlight color is controlled by the CursorLine highlight group

Example

With cursorline enabled, the current line has a subtle background color that follows the cursor as you move.

Tips

  • :set cursorcolumn highlights the column too
  • :highlight CursorLine ctermbg=236 customizes the color
  • Can be slow in very large files or complex syntax
  • Some color schemes include good cursorline colors
  • Toggle with :set cursorline!

Next

How do you yank a single word into a named register?