How to not get special characters in place of meta key combinations for VIM on OS X

依然范特西╮ 提交于 2019-12-04 11:19:49

问题


On OS X, at any program, when I type option-p I get π, option-P I get and there's a bunch of alt/option bindings that just return greek and other special characters.

Is there a way to disable that?

Currently I'm using the Auto Pairs VIM plugin and it has the following default mappings:

<M-p> : Toggle Autopairs (g:AutoPairsShortcutToggle) 
<M-e> : Fast Wrap (g:AutoPairsShortcutFastWrap) 
<M-n> : Jump to next closed pair (g:AutoPairsShortcutJump) 
<M-b> : BackInsert (g:AutoPairsShortcutBackInsert)

It seems I can't use these and other meta key based VIM mappings while this special input is turned on.

EDIT

From this cnet article, in truth I need to know how to disable that special input shown at the bottom of the page.


回答1:


Use the macmeta setting: :set macmeta

From :help 'macmeta'

'macmeta' Use option (alt) as meta key. When on, option-key presses are not interpreted, thus enabling bindings to <M-..>. When off, option-key presses are interpreted by the selected input method and inserted as text.

Obviously this is a MacVim-only setting.

In Terminal.app Settings there's a setting for "Use option as meta key", under the Keyboard tab which disables e.g. Option-p printing π. You may need to start a new terminal window to see the effect. But for some reason even after disabling this I'm having trouble setting mappings for <M-p>, but mappings using Ctrl-v and inserting the character literally do work.




回答2:


Well, it seems that with MacVim, in my .vimrc I can just map these special characters and it will work both at GUI and at Terminal.

Since they are generated by the corresponding meta key combinations, it'll look just as a meta key mapping.

EDIT

Some special characters are accents and it may not work well for them.

I've done this at my .vimrc:

if has("gui_macvim")
  let g:AutoPairsShortcutToggle     = 'π' " <m-p>
  let g:AutoPairsShortcutFastWrap   = '∑' " <m-w>
  let g:AutoPairsShortcutJump       = '∆' " <m-j>
  let g:AutoPairsShortcutBackInsert = '∫' " <m-b>
endif

has("gui_macvim") is true both at GUI as at Terminal, when running MacVim.



来源:https://stackoverflow.com/questions/11903889/how-to-not-get-special-characters-in-place-of-meta-key-combinations-for-vim-on-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!