Meta on Mac

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Meta on Mac

Haodong Du
Hi All,
I'm wondering if there is a way to enable meta key for vim on mac. I'm using it from terminal. I read an earlier post in the mail list about MavVim.app GUI. But I want to stick to the stock Vim. What I have found out working:

1. NeoVim works with <M-x> out of the box. Of course you need to turn on Meta emulation of your terminal.
2. Vim works with <M-n>-->˜ kind of mapping when turning meta emulation off.
3. Vim works with <ESC>n kind of mapping when turning meta emulation on.

So far, my best option seems to use <ESC>n types of mapping. But not sure if this kind of mapping works with linux or not. Also for plugins using Meta, I have to remap manually. I hope there are better options to have Meta natively on Mac.

Regards,
Haodong Du

--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/7a504a47-a86e-43a9-b017-b3ed4ce5ede1n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Meta on Mac

Bailey Stoner
If you’re in the default terminal app, you’ll need to go to the keyboard settings and change option to meta instead of the default :)

On Sat, Mar 6, 2021 at 14:27, Haodong Du <[hidden email]> wrote:
Hi All,
I'm wondering if there is a way to enable meta key for vim on mac. I'm using it from terminal. I read an earlier post in the mail list about MavVim.app GUI. But I want to stick to the stock Vim. What I have found out working:

1. NeoVim works with <M-x> out of the box. Of course you need to turn on Meta emulation of your terminal.
2. Vim works with <M-n>-->˜ kind of mapping when turning meta emulation off.
3. Vim works with <ESC>n kind of mapping when turning meta emulation on.

So far, my best option seems to use <ESC>n types of mapping. But not sure if this kind of mapping works with linux or not. Also for plugins using Meta, I have to remap manually. I hope there are better options to have Meta natively on Mac.

Regards,
Haodong Du

--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/7a504a47-a86e-43a9-b017-b3ed4ce5ede1n%40googlegroups.com.


--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/F0_yNBdm9hBt8ZgX1RDXu8I-5uFopBB_q5BHixOBlyH9uhqnfI204PnG1oqI8LupSlq_jy5TQVgdWzMEWcQaYtjma_9qKZNU0nLJ_bnJ9BA%3D%40monokro.me.
Reply | Threaded
Open this post in threaded view
|

Re: Meta on Mac

Tony Mechelynck
In reply to this post by Haodong Du
On Sunday, March 7, 2021 at 2:25:56 AM UTC+1 [hidden email] wrote:
Hi All,
I'm wondering if there is a way to enable meta key for vim on mac. I'm using it from terminal. I read an earlier post in the mail list about MavVim.app GUI. But I want to stick to the stock Vim. What I have found out working:

1. NeoVim works with <M-x> out of the box. Of course you need to turn on Meta emulation of your terminal.
2. Vim works with <M-n>-->˜ kind of mapping when turning meta emulation off.
3. Vim works with <ESC>n kind of mapping when turning meta emulation on.

So far, my best option seems to use <ESC>n types of mapping. But not sure if this kind of mapping works with linux or not. Also for plugins using Meta, I have to remap manually. I hope there are better options to have Meta natively on Mac.

Regards,
Haodong Du

I suggest a two-step solution:

map <Esc>x <M-x>  " IMPORTANT: do not use :noremap here
map <M-x> whatever

This way, for all the mappings thus defined, Esc and Meta will  be interpreted the same way. You may also want to set timeouts as follows:
'timeout'   (boolean) on
'timeoutlen' (milliseconds) slower than your slowest typing speed for the {lhs} of a single mapping
'ttimeoutlen' (milliseconds) faster than your fastest typing speed but slower than the interval between successive bytes sent by the system for a single keypress.

Best regards,
Tony.

--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/e62a398b-d8d9-41df-883b-c491661d1347n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Meta on Mac

Haodong Du
In reply to this post by Bailey Stoner
Thanks Bailey and Tony,

Turning on opt as Meta only sends a ESC before the character. Still, vim cannot recognize it as <M-x>. Instead <ESC>x mapping does work that way as I summarized.

A remapping of ESC to M- is what I just find in the fandom vim wiki. It appears to be working well. I don't quite understand why Vim developers chose not to enable this, since NeoVim seems to be recognizing ESC prefix as M-.
``
for i in range(97,122)
  let c = nr2char(i)
  exec "map \e".c." <M-".c.">"
  exec "map! \e".c." <M-".c.">"
endfor
``
Could you explain a bit about when I would need the timeout setting?  I'm using many combination keys with no issues so far.


On Sat, Mar 6, 2021 at 8:33 PM, Bailey Stoner <[hidden email]> wrote:
If you’re in the default terminal app, you’ll need to go to the keyboard settings and change option to meta instead of the default :)

On Sat, Mar 6, 2021 at 14:27, Haodong Du <[hidden email]> wrote:
Hi All,
I'm wondering if there is a way to enable meta key for vim on mac. I'm using it from terminal. I read an earlier post in the mail list about MavVim.app GUI. But I want to stick to the stock Vim. What I have found out working:

1. NeoVim works with <M-x> out of the box. Of course you need to turn on Meta emulation of your terminal.
2. Vim works with <M-n>-->˜ kind of mapping when turning meta emulation off.
3. Vim works with <ESC>n kind of mapping when turning meta emulation on.

So far, my best option seems to use <ESC>n types of mapping. But not sure if this kind of mapping works with linux or not. Also for plugins using Meta, I have to remap manually. I hope there are better options to have Meta natively on Mac.

Regards,
Haodong Du

--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/7a504a47-a86e-43a9-b017-b3ed4ce5ede1n%40googlegroups.com.


--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/F0_yNBdm9hBt8ZgX1RDXu8I-5uFopBB_q5BHixOBlyH9uhqnfI204PnG1oqI8LupSlq_jy5TQVgdWzMEWcQaYtjma_9qKZNU0nLJ_bnJ9BA%3D%40monokro.me.

--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/57e3241f-4aa8-4bd3-bdcf-e0d2739e98b3%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Meta on Mac

Haodong Du
Thanks Tony, I think I kinda understand why you mentioned setting timeout. With this setting, sometimes you get the upper-ed characters when you don't want it. Setting a timeout would help. TBH, this is not ideal. Thank you!


On Sat, Mar 6, 2021 at 8:50 PM, Haodong Du <[hidden email]> wrote:
Thanks Bailey and Tony,

Turning on opt as Meta only sends a ESC before the character. Still, vim cannot recognize it as <M-x>. Instead <ESC>x mapping does work that way as I summarized.

A remapping of ESC to M- is what I just find in the fandom vim wiki. It appears to be working well. I don't quite understand why Vim developers chose not to enable this, since NeoVim seems to be recognizing ESC prefix as M-.
``
for i in range(97,122)
  let c = nr2char(i)
  exec "map \e".c." <M-".c.">"
  exec "map! \e".c." <M-".c.">"
endfor
``
Could you explain a bit about when I would need the timeout setting?  I'm using many combination keys with no issues so far.


On Sat, Mar 6, 2021 at 8:33 PM, Bailey Stoner <[hidden email]> wrote:
If you’re in the default terminal app, you’ll need to go to the keyboard settings and change option to meta instead of the default :)

On Sat, Mar 6, 2021 at 14:27, Haodong Du <[hidden email]> wrote:
Hi All,
I'm wondering if there is a way to enable meta key for vim on mac. I'm using it from terminal. I read an earlier post in the mail list about MavVim.app GUI. But I want to stick to the stock Vim. What I have found out working:

1. NeoVim works with <M-x> out of the box. Of course you need to turn on Meta emulation of your terminal.
2. Vim works with <M-n>-->˜ kind of mapping when turning meta emulation off.
3. Vim works with <ESC>n kind of mapping when turning meta emulation on.

So far, my best option seems to use <ESC>n types of mapping. But not sure if this kind of mapping works with linux or not. Also for plugins using Meta, I have to remap manually. I hope there are better options to have Meta natively on Mac.

Regards,
Haodong Du

--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/7a504a47-a86e-43a9-b017-b3ed4ce5ede1n%40googlegroups.com.


--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/F0_yNBdm9hBt8ZgX1RDXu8I-5uFopBB_q5BHixOBlyH9uhqnfI204PnG1oqI8LupSlq_jy5TQVgdWzMEWcQaYtjma_9qKZNU0nLJ_bnJ9BA%3D%40monokro.me.

--
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/a2947b33-6318-4425-9561-55a295f3fc2f%40gmail.com.