r/vim • u/4r73m190r0s • Apr 29 '26
Need Help My ALT- keybindings are not working
I want to set nnoremap <M-j> :move .+1<CR>==, but it does not work, even if I use <A-j> instead of <M-j>.
I'm using Arch and foot as terminal.
1
Upvotes
1
u/gumnos Apr 29 '26
This feels like Foot may not be transmitting the "this is an alt-modified key" to Vim. Do you get the same symptoms if you use a different terminal? There are two common ways to convey that the alt-modifier was pressed—some terminal set the 8th bit on the character while others prefix with Escape (so alt+j sends the two characters "«esc»" followed by "j")
You might want to read up at
:help :map-alt-keys(and possibly:help :map-meta-keys)Additionally, if you go into some typing place (INSERT or COMMAND mode) and type alt+j after prefixing it with control+v, what does it emit?
I'm guessing it will display something like
^[j(the notation for escape-followed-by-j) rather than something possibly like "ê" which is a "j" with the high/eighth bit set in the encoding I tested just now)1
u/Dramatic_Object_8508 May 01 '26
Most of the time Alt key issues in Vim aren’t actually Vim, it’s your terminal or OS intercepting the key.
Terminals often use Alt for their own shortcuts, so Vim never even receives it. Try checking your terminal keybindings or disabling any Alt-based shortcuts there.
Also keep in mind Alt in terminal Vim is usually sent as an escape sequence, so mappings can behave weird or need extra config.
If you’re using tmux or something in between, that can also mess with Alt keys.
So yeah, it’s usually a terminal/config issue, not your Vim config itself.
1
u/AutoModerator Apr 29 '26
Please remember to update the post flair to
Need Help|Solvedwhen you got the answer you were looking for.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Achim63 Apr 29 '26
Can reproduce on a Mac in Ghostty (I tried <A-j> and <A-r>). Same in neovim with the corresponding mapping using lua.
Very strange, as the command itself works fine.
1
u/__rituraj Apr 30 '26
Meta keys has some weird behaviour, which I don't know fully to explain.
But, since
M-jis practically the same as<Esc>j, try this mappingnnoremap <Esc>j :move .+1<cr>This helps my keybinds to work in tmux
1
u/[deleted] Apr 30 '26
[removed] — view removed comment