5

Referring to the existing leftabove and rightbelow commands, which do the following:

  • execute a command
  • if the command results in a split, it will be either opened on the left, or above the current window for leftabove (and analogously for rightbelow).

Question is: why don't the counterparts rightabove and leftbelow exist? Wouldn't it be logical that I want my new split either on the right, or above? (Or either on the left or below?)

Addendum: I understand the wording of my question ("I want my new split either on the right, or above") might have been misleading. Let me try to make the question more clear.

leftabove means: if you encounter a vsplit then the new window should be on the left; if you encounter a split, then the new window should be above.

rightbelow means: if you encounter a vsplit then the new window should be on the right; if you encounter a split, then the new window should be below.

So what I'm asking is, why don't we have these two?

leftbelow means: if you encounter a vsplit then the new window should be on the left; if you encounter a split, then the new window should be below.

rightabove means: if you encounter a vsplit then the new window should be on the right; if you encounter a split, then the new window should be above.

3

Wouldn't it be logical that I want my new split either on the right, or above?

You never want your new split to be either on the right or above.

You either want your new split to be on the right, in which case you can use :rightbelow; or you want it above, in which case you can use :leftabove.

Maybe it would have been less confusing for the user if Vim had provided 4 distinct modifiers:

:splitabove
:splitbottom
:splitleft
:splitright

Although, Vim would have had to deal with possible nonsensical combinations, like:

:splitabove vsplit
:splitright split

Anyway, instead, it was chosen to provide only 2 modifiers, merging :splitabove and :splitleft into :leftabove; and merging :splitbottom and :splitright into :rightbelow. The command to which you apply the modifier will choose which part of the modifier to honor. For example, :split will honor the above part of :leftabove, while :vsplit will honor the left part. You have no control over which part is honored; the command following the modifier does.

5
  • Thanks, this was also my understanding, but it does not answer my question. I'll try to reword it a bit.
    – Attilio
    Sep 3 '20 at 15:27
  • With "either to the right or above" I meant something like: I want vsplit to go to the right and any split to go above. See addendum to the question.
    – Attilio
    Sep 3 '20 at 15:33
  • 1
    I don't know. All I can say is that I've never been in a situation where I felt I was missing leftbelow or rightabove, because I always know how a command is going to split the window (horizontally vs vertically). I could see how they are needed if there were some commands whose splitting direction was computed at runtime; but I can't think of any.
    – user938271
    Sep 3 '20 at 15:41
  • 1
    Ah, ok, now I understand what you are saying. Basically when you call :rightbelow, you know in advance that you will only use the right part of it.
    – Attilio
    Sep 3 '20 at 15:43
  • I thought about the question before reading the answer or these comments. FWIW the "you know ahead of time" idea is exactly how I would have described it, too. Perhaps, the answer can be modified to emphasize this and this one can be put to bed...
    – B Layer
    Sep 24 '20 at 7:00

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.