How can I have h and l move the viewport only by one column when they go beyond the left and right borders when nowrap
is active?
1 Answer
Simply do this:
set sidescroll=1
'sidescroll'
controls "the minimal number of columns to scroll horizontally". So with a value of 1 h
and l
will shift the screen one column at a time.
Side note: the commands zh
and zl
will shift the screen a column at a time but they don't move the cursor. If, for some reason, you couldn't or didn't want to change 'sidescroll'
you could do something like nnoremap zh zh<left>
to achieve the same effect.
-
1
-
-
1
zl
andzh
but it doesn't move the cursor. Does that work for you? Not sure if you can do it with cursor moving. But a mapping to do so should be doable.nnoremap zl zl<right>
h
to dozh
followed byh
, and similarly forl
. I'll try it out while waiting for answers.'sidescroll'