5

Is it possible to keep cursor in constant horizontal position (column) while scrolling window (or moving cursor) up and down?

For example if I have file with such lines:

This.is.a.test
Short.one

This.is.a.longer.line

(I put . in places where there is space)

When I have cursor at the end of "test" word and then move it down (or scroll window), cursor changes it's horizontal position to the last character of current line. It is quite annoying when I edit files with long lines without wrapping, because if I scroll window horizontally to some position and then want to go down some lines and there happend to be a short line, then my whole window is automatically scrolled horizontally to the end of this short line and I have to scroll it back to it's previous position manually.

How this behaviour can be changed?

6

The way I solve that is to set the 'virtualedit' option:

:set virtualedit=all
  • This solution doesn't work with vim 8.0, with -u NONE --noplugin. At least wrapping is enabled by default. – sevo Aug 24 '17 at 17:01
  • It works fine for me using Vim 8.0.691 in a terminal on Linux. Can you explain how it isn't working for you? – garyjohn Aug 25 '17 at 14:42
  • With this option, 9j keeps cursor column position, but scroll C-d moves cursor to the left. It turns out that I also need nostartofline. – sevo Oct 26 '17 at 21:13

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.