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).

New contributor
Harry is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
up vote 2 down vote accepted

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.

New contributor
Ralf is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 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 at 17:08

Your Answer

Harry is a new contributor. Be nice, and check out our Code of Conduct.
 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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