How to move vertical split window to horizontal split, when there is an existing horizontal split?

StackOverflow https://stackoverflow.com/questions/12774898

  •  05-07-2021
  •  | 
  •  

سؤال

In Vim I tend to open buffers in new vertical splits (with the occasional horizontal split). I keep my code to 80 chars wide, so this works pretty well on large monitors.

I often end up with this window arrangement:

---------------------
|    |    |    |    |
|    |    |    |    |
------    |  A |  B |
|    |    |    |    |
|    |    |    |    |
---------------------

At four or five columns wide, it can start getting a bit too narrow, so then I want to move the windows around so it looks like this:

----------------
|    |    |  A |
|    |    |    |
------    ------
|    |    |  B |
|    |    |    |
----------------

As far as I know, this is impossible to do by moving the windows in Vim.

The only way to get that window arrangement I've found, is to close window A, and then re-open A as a new horizontal split from window B.

Is that correct, or is there a way to move/re-arrange windows like that in Vim? Maybe a plugin?

I'm yet to find anything, so I thought I would ask because I find the opening/closing of windows anoying and breaks my flow.

FWIW, I find the Ctrl-W + J / Ctrl-W + K shortcuts useless, because they make the new horizontal split as wide as the whole screen, rather than splitting with the neighbouring window. I.e. Ctrl-W + J would give me this:

----------------
|    |    |    |
|    |    |    |
------    |  A |
|    |    |    |
|    |    |    |
----------------
|              |
|      B       |
----------------

Which is generally never what I want.

If anyone has some ideas, let me know!

هل كانت مفيدة؟

المحلول

There's a plugin that can do exactly what you want. Here's the link : https://github.com/fabi1cazenave/suckless.vim.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top