2

(Related to this other question of mine.)

Is there a concrete reason to why rotating the windows u, v, and [x,y,z] is not allowed?

Or is it just a limitation that could be lifted in future versions of Vim?

┌───────┬───────┬───────┬────────┐
│       │       │       │        │
│   x   │   y   │   z   │        │
│       │       │       │        │
├───────┴───────┴───────┤        │
│                       │        │
│           u           │        │
│                       │        │
├───────────────────────┤        │
│                       │        │
│           v           │        │
│                       │        │
├───────────────────────┴────────┤
│                                │
│                                │
└────────────────────────────────┘

I don't see why rotating that should lead to

┌───────────────────────┬────────┐
│                       │        │
│           v           │        │
│                       │        │
├───────┬───────┬───────┤        │
│       │       │       │        │
│   x   │   y   │   z   │        │
│       │       │       │        │
├───────┴───────┴───────┤        │
│                       │        │
│           u           │        │
│                       │        │
├───────────────────────┴────────┤
│                                │
│                                │
└────────────────────────────────┘
1
2

I see no technical reason this could not be achieved, so I'm going to speculate the answer is oversight and/or other priorities. It does rather complicate things, so it was simply not gotten around to. One immediate issue with relaxing this restriction is it becomes ambiguous whether ctrl-w r will move your window up/down or left/right, if you are in window x in the example given.

Originally, there were only a single type of split window (now called horizontal splits) in vim. In this situation, ctrl-w r has only one straightforward definition which is implemented by moving the first window to the end of the linked list and the last window to the front.

Vertical splits were added later, and this code was never significantly updated, except to prevent the situation described in the question. Complex splits are implemented with an additional "frame" data structure which would require extra work to achieve the desired result.

This code is also very old, the relevant function win_rotate was available in vim 3.0, circa 1994, and the modifications for vertical splits were added at least before mid 2004.

0

As mentioned in the help for CTRL-W_r, window rotation works only within the row/column that the current window is in.

The windows x, y, z, u, v are in the same column (as can be seen from the output of the winlayout() function).

:echo winlayout()
['col', [['row', [['col', [['row', [['leaf', 1007], ['leaf', 1006], ['leaf', 1005]]], ['leaf', 1004], ['leaf', 1003]]], ['leaf', 1002]]], ['leaf', 1000]]]

So when you rotate the windows, only these windows are rotated.

1
  • I know that, but I guess you have not seen my expected/desored result?
    – Enlico
    Sep 4 at 17:46

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.