I'm referring to plugins like gundo and nerdtree, which offer a whole lot of key bindings only when the cursor is their window.
Therefore, I was wandering if there's a common or preferred way to accoplish something like this.
The intuitive way, to me, seems pretty obvious: create a autocmd
that is triggered when the cursor moves into that window, and another one when it moves away from that windows. The two autocmd
s should activate the plugin-specific mappings and revert the original mappings/functionalities respectively.
However, I can't see how the latter can be done without having to write a list of "mappings to be recovered or removed".
The motivation for this question is that I'm considering writing a small plugin to make all window-related actions (like moving them, moving across them, opening them, closing them, ...) easier to perform, as described here.
<buffer>
argument tonnoremap
?:h :map-local
j
to do something plugin-specific, thenj
will be left with its normal meaning, and not mapped to<nop>
.WinEnter
andWinLeave
to load and unload them.