I have the following window arrangement in Vim:
┌─────┬─────┐
│ │ 2 │
│ 1 ├─────┤
│ │ 3 │
└─────┴─────┘
I want to swap windows 2 and 3. Now window 2 is active. CTRL-wJ wouldn't work, because it will then bring window 2 to the bottom and window 1 and 3 on the top as two vertically split windows.
After that, I tried to use other CTRL-wH/J/K/L movements, but wasn't able to achieve the final result.
How can one actually do that?
:h window-moving
(or simply :h windows
and then browsing down) lists all such stuff.
I believe you want CTRL-wCTRL-x (or CTRL-wx) (Window eXchange).
I do not believe that Matt's answer is what you are looking for. It only allows to swap the window with the next window. This may work for the given example but not for more complex situations.
I use the vim-windowswap plugin which allows to swap any two windows: https://github.com/wesQ3/vim-windowswap
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With