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

时光怂恿深爱的人放手 提交于 2019-12-03 06:45:30

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.

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.

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