nmap <C-Tab> ^Ww
nmap <CS-Tab> ^WW
This worked pretty well, in Win32 GVim and later in GTK+ GVim, but it
doesn't seem to work on MacVim. In fact, no mappings involving tab
with modifiers seem to do anything. For example, save the following to
~/tabtest.vim:
map <special> <Tab> :echo "Got Tab"<CR>
map <special> <C-Tab> :echo "Got Control-Tab"<CR>
map <special> <S-Tab> :echo "Got Shift-Tab"<CR>
map <special> <M-Tab> :echo "Got Alt-Tab"<CR>
...then run "mvim -u NONE -U NONE -S ~/tabtest.vim". All the mappings
show up properly in :map, and the mapping for <Tab> works, but no
amount of banging on the tab key with any combination of modifiers
seems to produce any messages at all.
Hi Tim,
I have looked into the Tab problems now and managed to fix some of
them (rev 260). The following mappings now work
:imap <Tab> Tab
:imap <S-Tab> S-Tab
:imap <M-Tab> M-Tab
:imap <S-M-Tab> S-M-Tab
but these do _NOT_ work
:imap <D-Tab> D-Tab
:imap <C-Tab> C-Tab
These last two are reserved by Mac OS X: <D-Tab> switches
applications, <C-Tab> moves the focus between "key views". Now, it
should be possible to override the <C-Tab> behaviour, but I haven't
figured out a reasonable way to do so yet. (Note <C-Tab> events never
even reach the text view, instead Cocoa seems to hard wire <C-Tab> to
"select next key view".)
/Björn
Thank you!
> but these do _NOT_ work
>
> :imap <D-Tab> D-Tab
> :imap <C-Tab> C-Tab
>
> These last two are reserved by Mac OS X: <D-Tab> switches
> applications, <C-Tab> moves the focus between "key views". Now, it
> should be possible to override the <C-Tab> behaviour, but I haven't
> figured out a reasonable way to do so yet. (Note <C-Tab> events never
> even reach the text view, instead Cocoa seems to hard wire <C-Tab> to
> "select next key view".)
Haw, just my luck. :) A quick google search didn't show me anything
particularly helpful about overriding this <C-Tab> behaviour (although
you might be able to snag the keyboard event by overriding sendEvent:
on your application or window objects), so I'll just have to stick
with the traditional old ^W keybindings. Thanks for looking into it,
though!
I just came across the Firefox equivalent of this bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=374076
Apparently you can't get NSKeyDown events for Ctrl-Tab, but you can
get NSKeyUp events.
Hmmm...would it be prudent to just ignore this for 10.4, since Apple
has fixed the problem with 10.5 (according to the above thread)?
/Björn
Well, I suspect 10.4 is going to be with us for a while yet (there's
still people on 10.3 after all), but it probably wouldn't hurt to at
least add something to the MacVim documentation saying "Yes, mapping
<C-Tab> doesn't work in 10.4, it's a limitation in Cocoa removed in
10.5".
I did some investigating and found that it works to intercept <C-Tab>
in -[MMApplication sendEvent:], but I am not sure if it breaks
something else (I doubt it, but please be on the alert). The latest
revision contains this hack (r315).
/Björn