4

Is the meta key supposed to do anything in vim? It would be nice if the things that can be done on the command line could also be done in insert mode (such as <M-t> for transposing words). As it is (on my mac with iterm configured to use the command key as meta), it serves only as a quicker alternative to the escape key, because <meta+b> = <esc>b.

I found a post saying one could put

" fix meta-keys which generate <Esc>a .. <Esc>z
let c='a'
while c <= 'z'
  exec "set <M-".toupper(c).">=\e".c
  exec "imap \e".c." <M-".toupper(c).">"
  let c = nr2char(1+char2nr(c))
endw

into .vimrc; but that only made my meta produce some useless symbols.

PS. I think the answer to this quæstion is simply no. Though it is useful for escaping to normal mode with the first command, <M-d>d for <esc>dd &c.

  • How did you set up iTerm to use Cmd as Meta? Also, could you clarify what you mean when you say "It would be nice if the things that can be done on the command line could also be done in insert mode."? – romainl Sep 21 '15 at 11:35
  • @romainl: Under profiles/keys, I set right opt = esc+, left opt = option. Then, under keys, I set right opt = right cmd, and left and right command = right opt. For second q, I’ll edit. – Toothrot Sep 21 '15 at 11:41
  • Is this what you are looking for: :set macmeta? If this option is set you can map things like <M-a> (Alt-a). – Andreas Sep 21 '15 at 14:41
  • @Andreas: Do you know if this can be done in the terminal version? – Toothrot Sep 21 '15 at 15:10
  • @Lawrence Just tried it in the terminal in OSX. It didn't like it. I use it in MacVim – Andreas Sep 21 '15 at 15:16
7

If you are able/willing to switch to Neovim, that has full support for meta key combinations, as documented here: https://github.com/neovim/neovim/blob/master/runtime/doc/vim_diff.txt#L86

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.