How do I scroll the view horizontally so the cursor sits at the leftmost or rightmost visible column?
Answer
zs and ze
Explanation
When nowrap is set and lines extend beyond the screen width, zs and ze snap the horizontal scroll position so the cursor sits exactly at the left or right edge of the visible screen area. This complements the incremental scroll commands zh/zl and the half-screen scroll zH/zL.
How it works
zs— scroll the view so the cursor column is the first (leftmost) visible columnze— scroll the view so the cursor column is the last (rightmost) visible column- Unlike
zhandzlwhich scroll by a fixed amount,zsandzesnap directly to the cursor position - Only meaningful when
set nowrapis active; withwrapthey have no visible effect
Example
With a very long line and set nowrap:
[much text before]...current_var = some_long_expression...[much text after]
↑ cursor here
- Press
zs— the view shifts socurrent_varis at the left edge of the screen - Press
ze— the view shifts socurrent_varis at the right edge, showing more of what came before
Tips
- Use
zsafter jumping to a deep column (e.g., after a/patternsearch) to reveal context to the right - Use
zeto peek at what precedes the cursor on a long line zH/zLscroll half a screen width and don't depend on cursor position — useful for scanning long lines systematically