2

Currently my Vim layout is this one :

________________________
| N |         |         |
| E |         |         |
| R |         |         |
| D |         |         |
| T |---------|         |
| r |         |         |
| e |         |         |
| e |         |         |
|-----------------------|
|                       |
|                       |
|_______________________|

The left window is NerdTree.

What should I do to get the same layout as below ?

________________________
| N |         |         |
| E |         |         |
| R |         |         |
| D |         |         |
| T |         |         |
| r |---------|---------|
| e |         |         |
| e |         |         |
|   |         |         |
|___|_________|_________|

With Ctrl-w and the H, J, K, L I can't reach the wished result.

2 Answers 2

1

The simplest built-in way to do this is the function win_splitmove. Given the layout you start with,

call win_splitmove(5, 4)

will result in the desired layout, up to specific windows chosen. In other words, we are moving window 5, bottommost, to become a new split window of window 4, rightmost (technically the window numbering in your first example is predictable, but in the second example it is not determinable from the diagram).

As Vivian De Smedt points out, working with partial splits using <c-w> is difficult since vim is missing some fundamental movements. I maintain a plugin which closes this gap a bit, https://github.com/andymass/vim-tradewinds. This plugin leverages win_splitmove and offers the maps <c-w>g{h,j,k,l} by default.

While the task still cannot be accomplished in one movement, it can be in two.

  1. Move the bottom window using built-in <c-w>L.
________________________
| N |         |    |    |
| E |         |    |    |
| R |         |    |    |
| D |         |    |    |
| T |---------|    |    |
| r |         |    |    |
| e |         |    |    |
| e |         |    |    |
|___|_________|____|____|
  1. Move the same, now rightmost window into the second to rightmost window using the plugin's <c-w>gh map.
________________________
| N |         |         |
| E |         |         |
| R |         |         |
| D |         |         |
| T |---------|---------|
| r |         |         |
| e |         |         |
| e |         |         |
|___|_________|_________|

1
  • I'll stick on the solution without plugin to become one day ... a vim expert (as you are :) Commented Nov 25, 2022 at 22:13
0

I believe you can't.

In the first figure you have 1 partial horizontal split. In the second you have two.

The Ctrl-w moves can only decrease the number of such split.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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