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

How do I scroll the view left and right one column at a time when line wrapping is off?

Answer

zh and zl

Explanation

When wrap is disabled, long lines extend off-screen. The zh and zl commands scroll the view horizontally one column at a time — zh shifts the view left (revealing content to the left) and zl shifts it right. Unlike zH/zL which jump half a screen width, these give you fine-grained control.

How it works

  • zh — scroll view left by one column (or {count} columns with a count prefix)
  • zl — scroll view right by one column (or {count} columns with a count prefix)
  • zH — scroll left by half a screen width
  • zL — scroll right by half a screen width
  • zs — scroll so the cursor column is at the leftmost visible column
  • ze — scroll so the cursor column is at the rightmost visible column

Example

With :set nowrap and a 200-character line, the cursor is mid-line but the beginning is off-screen:

...nction processData(input []byte) (Result, error) {

Press 5zh to scroll 5 columns left, revealing more context:

func processData(input []byte) (Result, error) {

Tips

  • Add :set sidescrolloff=5 to keep at least 5 columns of context visible when the cursor moves horizontally — this pairs well with zh/zl
  • :set sidescroll=1 makes horizontal scrolling smoother (scroll one column at a time instead of jumping)
  • Both zh/zl and zH/zL are no-ops when wrap is on

Next

How do I open the directory containing the current file in netrw from within Vim?