0

Below, I call V1 the original viewport and V2 the new one.

  1. Start vim and write 5 sample lines. Leave the cursor in the last line.
  2. Issue :split.
  • Expected behavior: V2 is opened below. V1 is inaltered, except that V2 now occupies the lower half lines previously displayed by V1.
  • Actual behavior: V2 is opened below. V1 has been scrolled down by two lines.

Bear in mind that also happens with viewports full of text. The scroll is apparently proportional to the vertical position of the cursor relative to the top line and does not occur if the cursor is in the top line or the next-to-top line.

Is there any good reason for that behavior? For me, it is simply disorienting. Can it be disabled without changing the cursor position in V1? I did not find anything relevant in the docs.

PS: This is reproducible with vim -u NONE.

  • 1. There's no such thing as "viewport". It's called "window". 2. After split you always get into the new window, even though you think it's an old one. – Matt Jul 31 at 15:41
  • @Matt 1. The main answer in Vi&Vim states otherwise. You may want to explain why it is wrong. But from :help :split: "Split current window in two. The result is two viewports on the same file." I don't think the help would mention an inexistent feature. 2. Why do you think I think that? – Quasímodo Jul 31 at 16:22
1

I think this happens because vim always keeps your cursor visible: if it's covered by another window, vim jumps to make the line visible.

The stable windows plugin tries to address this problem.

| improve this answer | |

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.