How do I highlight the entire column under the cursor to help with aligning data?
Answer
:set cursorcolumn
Explanation
:set cursorcolumn (or the short form set cuc) highlights the entire vertical column where the cursor sits, painting a visible strip from top to bottom of the window. This is especially helpful when reading columnar data like log files or YAML, verifying indentation levels, or aligning values across many lines.
How it works
:set cursorcolumn— Enable the column highlight. The active column is styled using theCursorColumnhighlight group.:set nocursorcolumn— Disable it.:set cursorcolumn!— Toggle on/off.
Pair it with :set cursorline to highlight both the row and the column, creating a crosshair effect that precisely pins the cursor's position:
set cursorline
set cursorcolumn
Example
With cursorcolumn enabled while the cursor is on the e in name:
id name role
── ──── ────
1 Alice admin
2 Bob user
3 Carol user
The n column is shaded vertically across every row, immediately showing alignment.
Tips
-
Customize the column color by overriding the highlight group in your config:
highlight CursorColumn ctermbg=235 guibg=#2d2d2d -
The column highlight can slow down rendering in very wide files. Disable it for large CSV/log files if you notice lag.
-
Use
:set colorcolumn=80(a different option) to mark a fixed column position;cursorcolumnfollows the cursor wherever it moves.