RedditPP Mascot

RedditPP

r/vim • … • u/EgZvor

A twist on window navigation

Recently I've started using xmonad and decided to translate its window navigation model to Vim. The upside is it uses only 2 directions (and therefore 2 mappings) to traverse all the windows. Vim already has a flat enumeration of windows built-in, so it works pretty well. Perhaps, modulo arithmetic can be simplified.

nnoremap <expr> <c-down> (winnr() % winnr('$')) + 1 .. '<c-w>w' nnoremap <expr> <c-up> ((winnr('$') + winnr() - 2) % winnr('$')) + 1 .. '<c-w>w'

— 0