How do I scroll the view left or right when lines extend beyond the screen width?
Answer
zH / zL / zh / zl
Explanation
When :set nowrap is active and lines extend beyond the screen width, Vim clips the view. The zH, zL, zh, and zl commands scroll the view horizontally — left and right — to reveal the hidden portions of long lines.
Horizontal scroll commands
| Command | Action |
|---|---|
zl |
Scroll view right by 1 column (show more of the right side) |
zh |
Scroll view left by 1 column (show more of the left side) |
zL |
Scroll right by half the screen width |
zH |
Scroll left by half the screen width |
zs |
Scroll so the cursor column is at the left edge |
ze |
Scroll so the cursor column is at the right edge |
When to use this
Horizontal scrolling is only meaningful with :set nowrap. With wrapping on, all content is visible and these commands have no effect.
Example
Viewing a wide CSV or log file:
:set nowrap
zL " jump right by half screen to see more columns
zH " jump back left
5zl " scroll 5 columns right
Tips
{N}zl/{N}zhscroll N columns at a timezsis useful to snap the view to the cursor position after navigating with$to a long linesidescrolloffcontrols the minimum number of columns kept visible around the cursor (likescrollofffor vertical):set sidescroll=1makes horizontal scrolling smooth (1 column at a time) instead of jumping by large chunks- These are distinct from the normal
$/0motions — those move the cursor, these scroll the view