macvim-dev / macvim

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

Add a feature to map left Option `⌥` key to Meta #1321

Open huyz opened 1 year ago

huyz commented 1 year ago

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.

I don't really use accented characters using the macOS compose key. So I like to treat the left Option key as an additional modifier for more key mapping space. Creating these mappings for the text version of vim running inside of iTerm works great because I have the setting "Left Option key: Esc+".

The problem is that in MacVim, the Left Option key continues to act like the macOS Compose key. That means that I have to add to my .vimrc a bunch of mappings like:

nmap ß <M-s>
imap ß <M-s>

Describe the solution you'd like Like VimR, let me map the left Option key as Meta: screenshot 2022-10-21T045627Z

Describe alternatives you've considered Add a bunch of alias mappings like:

nmap ß <M-s>
imap ß <M-s>
ychin commented 1 year ago

Summary: For now, you can add :set macmeta to vimrc, which will do the same thing. For historical reasons, it's a Vim configuration (meaning you need to call it in Vim or set it in vimrc) instead of a GUI option like VimR. However, doing so will convert both left and right Option keys as Meta, but if you don't care about accent keys, you can just set that.


More details:

That said, I do intend to tackle input handling in a future release, probably the next one (after the current one I'm working on): https://github.com/macvim-dev/macvim/milestone/22. It's a lot easier to do everything in one go as I go around tackling different parts of the problem. For one, MacVim needs to implement "modifyOtherKeys", or in plain terms "Being able to handle Ctrl-I and Tab differently". The other aspect is that you would not need to think about "Meta" keys at all. After all, "meta" keys are a complete implementation detail, and you shouldn't need to think about it and should be able to to map something like <M-i> as is without configuration, while still preserving the ability to do accent keys. There are still some details that I'm ironing out, but just a heads up for that. If you use the binary release, you would see from the release notes when I make that change and can switch to using the new settings as I deprecate set macmeta. For now you can just use that option (when I say "deprecate" I don't mean it will stop working, just that it would no longer be the preferred way of doing things)

huyz commented 1 year ago

Thanks @ychin, I appreciate the tip, your future plans, and your explanation