github github
stars 17
issues 0
subscribers 1
forks 0



7 months ago


ventana.nvim provides 2 main commands: VentanaTranspose & VentanaShift, whose actions can be seen in the preview below. The active window and window sizes are preserved after the operations.


Flips all your windows along the main diagonal running from the top left corner to the bottom right corner, much like the matrix transpose operation in linear algebra.



An improved version of Vim's built-in CTRL-W r window rotation command, which only works for linear windows on the same split level. If you try to do the rotation against a split that has sub-splits of its own, you'd encounter the E443: Cannot rotate when another window is split error. This command shifts your top level splits as you'd expect them to.



There is also a 3rd bonus command VentanaShiftMaintainLinear, which is like VentanaShift, but instead of keeping the sizes of each window-buffer pair the same, it maintains the exact layout of each window's position & size, and only shuffles the buffers across them. This only works for "linear" layouts, which are layouts containing a single row or column of leaf windows only. If you were to execute this command on a non-linear layout, it would simply fallback to the same behavior as VentanaShift.



Personally I'm on Neovim v0.10, but any version that has the winlayout() function should suffice. You can confirm its existence with the command :echo winlayout().


The plugin can be installed in the usual manner using your package manager of choice. For example, with lazy.nvim:

{ 'jyscao/ventana.nvim' }


There is no real configuration as of now, although that may change in the near future should I add additional features.

No default mappings are provided, but here are the mappings I personally use:

vim.keymap.set("n", "<C-w><C-t>", "<Cmd>VentanaTranspose<CR>")
vim.keymap.set("n", <C-w><C-f>",  "<Cmd>VentanaShift<CR>")
vim.keymap.set("n", <C-w>f",      "<Cmd>VentanaShiftMaintainLinear<CR>")

Known Issues

  • temporary buffers, such as those used for vim-fugitive's commit & linediff.vim's diffing, cannot be properly restored
  • when shifting 2 or more windows that have the same buffer open, the active window cannot be reliably returned to its pre-shift state; I do plan on fixing this at some point

Finally, just a note that even though I do use this plugin myself everyday, and find it to be a good addition to my workflow, I make no guarantees about its correctness. Should you encounter a bug, please open an issue.


Much of the implementation details, especially for getting and setting the windows layout tree, have been borrowed from nvim-dbee, which in turn owes its underlying logic to this excellent answer on the Vi and Vim StackExchange.