Alt and Apple keys in Vim/MacVim using a MacBook Pro

1,965 views
Skip to first unread message

i0n

unread,
Mar 20, 2011, 7:37:24 PM3/20/11
to vim_mac
Hi there.

I've already googled this topic quite a bit, but I haven't really
found much definitive information, so I figured I'd ask here. If I'm
asking this in the wrong place, just point me in the right direction.

I recently switched to Vim, I've been using Vim 7.3 (compiled from
source) in iTerm2 and MacVim (snapshot 57) on my MacBook Pro (running
10.6.6). In both I'm having trouble with mappings to the alt and
command keys.

Vim:

With Vim in the terminal, mappings to <A-something> <M-something> and
<D-something> do not work.



MacVim:

<D-something> works fine.
If macmeta is off then <A-something> and <M-something> do not work.
If macmeta is on then <M-something> works, at the expense of losing
mappings to some characters (and having to remap them)


I live in England, my keyboard layout is for GB.

So I guess my question is:

How can I write mappings for the alt and command keys so that they
will be recognised in Vim and MacVim? It would probably be enough if
just one of them worked....

i0n

unread,
Mar 20, 2011, 10:04:14 PM3/20/11
to vim_mac
I've just discovered that mapping to the alt character output works
for both Vim and MacVim on my system so for instance:

:imap ≥ =>

works in place of :imap <A-.> =>

Strangely shift-return in terminal doesn't map this way but aside from
that seems that everything else behaves the same across Vims.
This solves my immediate issue, I'd still be interested to hear the
low-down on what's actually going on.

Dave Land

unread,
Mar 21, 2011, 1:54:44 AM3/21/11
to vim...@googlegroups.com
On Mar 20, 2011, at 4:37 PM, i0n wrote:

> <clipped>


>
> Vim:
>
> With Vim in the terminal, mappings to <A-something> <M-something> and
> <D-something> do not work.

I bet that the <D-something> commands can't work because the terminal
emulator app or the Mac UI is capturing them. Not sure you're going to
be able to work around that one.

I don't use MacVim (I use Bram Moolenaar [et al]'s Vim, sorry I can't
help you on the latter portion of your email.

Dave


björn

unread,
Mar 21, 2011, 2:26:05 PM3/21/11
to vim...@googlegroups.com
On 21 March 2011 06:54, Dave Land wrote:
> On Mar 20, 2011, at 4:37 PM, i0n wrote:
>
>> <clipped>
>>
>> Vim:
>>
>> With Vim in the terminal, mappings to <A-something> <M-something> and
>> <D-something> do not work.
>
> I bet that the <D-something> commands can't work because the terminal
> emulator app or the Mac UI is capturing them. Not sure you're going to
> be able to work around that one.

The Cmd flag cannot (?) be detected in Terminal so if you want to bind
to Cmd you need to use a GUI port of Vim.

> I don't use MacVim (I use Bram Moolenaar [et al]'s Vim, sorry I can't
> help you on the latter portion of your email.

I keep seeing comments like this so I feel compelled to say that
MacVim = Vim with a GUI. There are a few extra features like full
screen, but I've tried very hard to not make MacVim too different from
other GUI ports of Vim.

Björn

Ben Schmidt

unread,
Mar 22, 2011, 5:37:26 AM3/22/11
to vim...@googlegroups.com, björn
> I keep seeing comments like this so I feel compelled to say that
> MacVim = Vim with a GUI. There are a few extra features like full
> screen, but I've tried very hard to not make MacVim too different from
> other GUI ports of Vim.

I wanted to point this out, too.

MacVim is just as much Vim as the GTK, Athena, Win32, etc. GUIs are.

Perhaps it is MacVim's home page that is misleading people, where it
currently says, "MacVim is a port of the text editor Vim to Mac OS X."
Making that wording more accurate might clarify things.

Ben.

björn

unread,
Mar 24, 2011, 9:48:43 AM3/24/11
to Ben Schmidt, vim...@googlegroups.com

Any suggestions on how to make it less confusing?

Björn

Janusz Bossy

unread,
Mar 24, 2011, 10:22:53 AM3/24/11
to vim...@googlegroups.com, björn, Ben Schmidt
On Thu, Mar 24, 2011 at 2:48 PM, björn <bjorn.w...@gmail.com> wrote:
>> Perhaps it is MacVim's home page that is misleading people, where it
>> currently says, "MacVim is a port of the text editor Vim to Mac OS X."
>> Making that wording more accurate might clarify things.
>
> Any suggestions on how to make it less confusing?

Maybe just: "MacVim is Vim for your Mac" :)

Janusz

Ben Schmidt

unread,
Mar 24, 2011, 1:17:37 PM3/24/11
to Janusz Bossy, vim...@googlegroups.com, björn

I like it.

Another description that comes to mind is something like this, depicting MacVim
more like a bridge: "MacVim brings together Vim--the Vi IMproved text editor--and
Apple's Aqua user interface." But I think the one above is probably better.

Ben.


dacresni

unread,
Mar 25, 2011, 8:28:12 PM3/25/11
to vim...@googlegroups.com, Janusz Bossy, björn, Ben Schmidt
perhaps more like MacVim is an Aqua GUI for Vim, like Gvim is a GTK gui for Vim.
Reply all
Reply to author
Forward
0 new messages