I'm trying to map * for resizing windows like this in my vimrc:
map * <C-W>-
This doesn't work in normal mode but works when using visual mode.
(by pressing <C-W>- manually, it works in normal mode)
Is there a reason why it doesn't work with my mapping? How can I use asterisk in normal mode?
map * <C-W>- is a recursive mapping: if anything in that mapping is already mapped to something else at the time of usage it is that something else that will be executed.
It is generally advised to use non-recursive mappings for most mappings except when you purposely use another mapping in your mapping.
The non-recursive variant of your mapping would be:
noremap * <C-W>-
Note that :map covers normal mode, visual mode, select mode, and operator-pending mode which may have unintended consequences. You should always use the most specific command available, in this case:
nnoremap * <C-W>-
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