macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.53k stars 685 forks source link

Alt Mapping does not work on gvim #1198

Closed sgon00 closed 1 year ago

sgon00 commented 3 years ago

Actually, Alt Mapping does not work on both vim and gvim. But I actually give up vim so far. At least, gvim should work, but it doesn't.

$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 01 2021 08:32:44)
macOS version - x86_64
Included patches: 1-2681
Compiled by Homebrew

OS: MacOS Big Sur 11.4

I have the following in .vimrc

set macmeta
map <M-Up> :bp<CR>
map <M-Down> :bn<CR>
map <S-Up> :bp<CR>
map <S-Down> :bn<CR>

Shift+Up/Down works. But Alt+Up/Down does NOT work at all in gvim. Btw, I have tired to add and remove set macmeta, nothing really happens with this set.

ychin commented 3 years ago

That should work. When you said you have tried to add and remove set macmeta, nothing happens. Are you saying you manually used set macmeta in MacVim? Or just adding/removing that line in your vimrc. It could be something else unsetting the macmeta setting in your vimrc.

When you are in MacVim, use :set macmeta? and it will tell you whether you have it set or not. Then you can try to manually set it again by using :set macmeta and it should work. If it doesn't, type map <M-Up> and see what it says?

Let me know if that helps or not.

sgon00 commented 3 years ago

@ychin thank you very much for your reply. By following your instructions, I found the problem, although that is not the same as what you thought. The problem is nothing related to set macmeta. The problem is the map commands are not working in .vimrc. If I manually map it with :map <M-Up> :bp<CR> in a running vim session, it works as expected. I have tried to remove set macmeta completely from .vimrc and do not set it manually either. That doesn't stop :map <M-Up> :bp<CR> working. So the problem is somehow map <M-Up> :bp<CR> does NOT work, but map <S-Up> :bp<CR> works in .vimrc. In other words, Alt Mapping does not work in .vimrc. Do you have any ideas why? Thanks a lot.

ychin commented 2 years ago

I forgot to get back to this, but what you said should work. Have you tried using noremap instead of map just for sanity's sake? If this issue still persist for you today, maybe try to use noremap, and clear your vimrc to just the mapping so it's easier to catch issues related to other parts of your vimrc.

eirnym commented 2 years ago

I have following key bindings in my vimrc. They will work with macmeta is on. MacVim version 173. I have these bindings for years

nmap <M-j> mz:m+<CR>`z
nmap <M-k> mz:m-2<CR>`z
ychin commented 1 year ago

Closing this issue for now, as I'm pretty sure mapping <M-UP> does work.

Btw, I have tired to add and remove set macmeta, nothing really happens with this set.

If I have to guess, your issue is that you unset macmeta. You are supposed to keep it on permanently. This will change in near future anyway when it gets deprecated. But for now, just don't unset macmeta and it should work.