macvim icon indicating copy to clipboard operation
macvim copied to clipboard

Alt Mapping does not work on gvim

Open sgon00 opened this issue 3 years ago • 4 comments

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.

sgon00 avatar Jun 07 '21 04:06 sgon00

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.

ychin avatar Jul 06 '21 22:07 ychin

@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.

sgon00 avatar Jul 07 '21 03:07 sgon00

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.

ychin avatar Aug 06 '22 11:08 ychin

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

eirnym avatar Aug 06 '22 12:08 eirnym

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.

ychin avatar Mar 27 '23 02:03 ychin