I am quite new to Vim and am trying to configure gVim with some of the behaviour that I like from notepad++.

I disabled text wrapping with :set nowrap, then added the horizontal scrollbar with :set guioptions+=b.

However, if I scroll horizontally to the right, scrolling vertically then forces the horizontal scrollbar all the way back to the left. I would like the horizontal position to stay fixed while I scroll vertically. Is there some way to do this?

I get the same behaviour under both linux (CentOS 6) and Windows 7 (64-bit).

1 Answer 1


By default the cursor is always on a column that contains real text.

1 2 3 4 5 6 7 8 9
1 2 3 4 5
1 2 3 4 5 6 7 8 9

If your cursor is in line 1 on the character '9' and you move down, the cursor "jumps" to the character '5' in the second line. If you move down again, it jumps to the '9' in the third line. Because of this change of the cursor column, the horizontal scrollbar changes.

If you want the cursor always on the column of the character '9' (even when there is no text), you have to do set virtualedit=all.

See :help virtualedit and read the entire section. It contains a warning that this setting might break plugins or Vim scripts.

  • Thanks for the clear explanation. Like you say, it's not ideal, but I guess this is as close as I can get with gVim.
    – Harry
    Nov 10, 2018 at 17:08

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.