I usually press alt + ,
to insert <
, it works fine in my zsh terminal and on every other application, but unfortunatly not on vim or neovim.
I tried following but nothing worked:
map <M-,> "<"
map <M-,>='<'
I appreciate any help
I usually press alt + ,
to insert <
, it works fine in my zsh terminal and on every other application, but unfortunatly not on vim or neovim.
I tried following but nothing worked:
map <M-,> "<"
map <M-,>='<'
I appreciate any help
Everything is wrong, here.
First, you can't expect any of those mappings to do anything in insert mode because the :map
command creates mappings for normal, visual, and operator-pending modes, not for insert mode. The first thing to change is thus to use the proper :map
variant:
imap <M-,> "<"
imap <M-,>='<'
Second, the left-hand side of a mapping (the keys you want to press) and the right-hand side (what you want Vim to press instead) are supposed to be separated by whitespace so your second example wouldn't produce a mapping to begin with. It asks Vim to list insert mode mappings that contain <M-,>='<'
, which is pointless.
Third, the right-hand side of a mapping is a macro, where every character is used as if you typed it. "<"
would literally insert a double quote, an angle bracket, and a double quote. If you want the mapping to insert a <
, use a <
:
imap <M-,> <
Fourth, I've heard that Neovim handles the Meta/Alt key better than Vim so the mapping above is still likely to be problematic in Vim, depending on the OS or the keyboard layout. For example, in Vim on macOS with the AZERTY layout, the system translates Alt+,
to ∞
before it even reaches Vim so <M-
and <A-
mappings simply don't work reliably.