Search code examples
vimkeyboard-shortcutsneovim

How to navigate window splits in Vim in a round-robin fashion


I have found the information on how to navigate the Vim window splits using hjkl. But does there exist any way to use just one key to navigate through all of the windows in a round robin fashion?

For example, I have 2 vertical splits with 2 horizontal splits in each, i.e. I have 4 window splits and I just want to circle around them infinitely using single key.

I had this functionality in previous Vim version that I used, however since the installation of a NvChad I don't have this anymore and have to write it for myself.

Finding information on the internet hasn't resulted in any success.


Solution

  • You may not have to write anything yourself after all. Vim's :help windows gives you all the window commands. Reading through it, the first item that sounds as if it would do what you want is <C-W>w.

    Quoting from :help CTRL-W_w:

    move cursor to window below/right of the current one. If there is no window below or right, go to top-left window.

    By the way, <C-W><C-W> does the same, which is very convenient because you don't have to release Ctrl while hammering in 'w's.

    Go back the opposite direction with <C-W>W (that's a capital 'W' as opposed to the original command's lower case 'w').