This question looks like How to keep cursor horizontal position while scrolling in VIM? but it's actually not.

Vim always tries to snap the cursor to the first non-whitespace character of the destination line while scrolling.

Consider this text:

    Line 2

Now the cursor points to 'A', when I press <C-d> to scroll a half page, Vim will automatically snap the cursor to 'L' in the second line.

What I want is to remain the horizontal position of cursor unless I explicitly command Vim to do so (like 'h', 'l').


The option you want is 'startofline'. Specifically, you want to turn it off since it is on by default:

:set nostartofline


:help 'startofline'

(with the single quotes as part of the help command)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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