1

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?

4
  • 1
    I know you can scroll horizontally by a column at a time with zl and zh 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>
    – B Layer
    Commented Oct 14, 2020 at 19:10
  • 1
    @BLayer, at least it allows a kind of workaround. I could map h to do zh followed by h, and similarly for l. I'll try it out while waiting for answers.
    – Enlico
    Commented Oct 14, 2020 at 19:13
  • 1
    Exactly what I had in mind.
    – B Layer
    Commented Oct 14, 2020 at 19:13
  • Oooh, maybe 'sidescroll'
    – B Layer
    Commented Oct 14, 2020 at 19:22

1 Answer 1

3

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.

3
  • 1
    Simeone said someone :P
    – Enlico
    Commented Oct 14, 2020 at 19:36
  • LOL, hey what can I say? :)
    – B Layer
    Commented Oct 14, 2020 at 19:37
  • 1
    what can I say. Thank youuu
    – Enlico
    Commented Oct 14, 2020 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.