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 widthzL— scroll right by half a screen widthzs— scroll so the cursor column is at the leftmost visible columnze— 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=5to keep at least 5 columns of context visible when the cursor moves horizontally — this pairs well withzh/zl :set sidescroll=1makes horizontal scrolling smoother (scroll one column at a time instead of jumping)- Both
zh/zlandzH/zLare no-ops whenwrapis on