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 cursorlineenables the highlight:set nocursorlinedisables it- The highlight color is controlled by the
CursorLinehighlight group
Example
With cursorline enabled, the current line has a subtle background color that follows the cursor as you move.
Tips
:set cursorcolumnhighlights the column too:highlight CursorLine ctermbg=236customizes the color- Can be slow in very large files or complex syntax
- Some color schemes include good cursorline colors
- Toggle with
:set cursorline!