Default binding for Cmnd-W

3 views
Skip to first unread message

David Morel

unread,
Jan 15, 2008, 9:40:46 AM1/15/08
to vim...@googlegroups.com
Hi all,

I posted a bug recently on the googlecode tracker about an issue I
have with MacVim, Cocoa version. The default binding for Cmnd-W is :q,
which might seem logical. However, :q closes the editor, not the
buffer, and this is especially annoying in the cas of one tab per
file. It means it merelyy closes the tab, but the buffer stays
available to all other tabs, which is not the desired effect imho. To
illustrate it, a :tab ball restores all the open buffers in their
tabs. Am I using it in a wrong way, is there a workaround (except
mapping a different combination/patching the source/etc.)? Hints
welcome :)

David Morel

PGP.sig

travis

unread,
Jan 15, 2008, 12:34:47 PM1/15/08
to vim_mac
Just map it in your .vimrc file?
>  PGP.sig
> 1KDownload

Nico Weber

unread,
Jan 15, 2008, 2:48:26 PM1/15/08
to vim...@googlegroups.com
Hi,

there has been a (quite short) discussion on this: http://groups.google.com/group/vim_mac/browse_thread/thread/aecebc3e50e4698a

Adding

map <D-w> :bd<cr>
imap <D-w> <C-o>:bd<cr>

to your _vimrc should do the trick though.

HTH,
Nico

David Morel

unread,
Jan 15, 2008, 4:29:00 PM1/15/08
to vim...@googlegroups.com
Sorry for breaking the thread, seems my subscription on googlegroups
was borked. I re-subscribed but didn't get the answers to my post.
Here we go:

>> I posted a bug recently on the googlecode tracker about an issue I
>> have with MacVim, Cocoa version. The default binding for Cmnd-W
>> is :q, which might seem logical. However, :q closes the editor, not
>> the buffer, and this is especially annoying in the cas of one tab
>> per file. It means it merelyy closes the tab, but the buffer stays
>> available to all other tabs, which is not the desired effect imho.
>> To illustrate it, a :tab ball restores all the open buffers in their
>> tabs. Am I using it in a wrong way, is there a workaround (except
>> mapping a different combination/patching the source/etc.)? Hints
>> welcome :)
>
> there has been a (quite short) discussion on this:
> http://groups.google.com/group/vim_mac/browse_thread/thread/

aecebc3e5...
> Adding

> map <D-w> :bd<cr>
> imap <D-w> <C-o>:bd<cr>

> to your _vimrc should do the trick though.

Well, it doesn't. I tried that of course, and to make sure I verified
with :map and also mapped silly debug output to <D-w> but it seems to
be hardwired somewhere, and doesn't change the default behaviour. Can
someone test it and confirm I'm going nuts (or preferably that I'm
not)? Thanks :)

David Morel

PGP.sig

björn

unread,
Jan 16, 2008, 4:24:08 AM1/16/08
to vim...@googlegroups.com

Just quickly: the problem is that <D-w> is bound to a menu item and
such bindings override normal :map commands (check :h macmenukey). I
suggest you add the following to your .gvimrc

macmenukey <D-w>


map <D-w> :bd<cr>
imap <D-w> <C-o>:bd<cr>

or simply

macmenukey <D-w> :bd<cr>


Good luck,
Bjorn

David Morel

unread,
Jan 16, 2008, 5:06:24 AM1/16/08
to vim...@googlegroups.com

Le 16 janv. 08 à 10:24, björn a écrit :

>
> Just quickly: the problem is that <D-w> is bound to a menu item and
> such bindings override normal :map commands (check :h macmenukey). I
> suggest you add the following to your .gvimrc
>
> macmenukey <D-w>
> map <D-w> :bd<cr>
> imap <D-w> <C-o>:bd<cr>
>
> or simply
>
> macmenukey <D-w> :bd<cr>

I ended up using the first form you proposed:

" Make the cmnd-w key close the buffer, not the window
macmenukey File.Close
no <D-w> :bd<cr>
ino <D-w> <Esc>:bd<cr>

Works like a charm, thanks a lot!

Couldn't make the second one work, though, but -to me- that's np.

Thanks again

David

björn

unread,
Jan 17, 2008, 8:17:54 AM1/17/08
to vim...@googlegroups.com

Sorry, I was typing in a hurry...if you check ":h macmenukey" you'll
see that it is used to set up the key combination you have to press to
activate a menu item. So

macmenukey File.Close <D-w>

associates the "File.Close" menu item with <D-w> (which is already
done in $VIM/gvimrc). Now, to change the actual binding you have to
use the "menu" commands in Vim. Something like

aunmenu File.Close
amenu File.Close :bd<cr>

should do what you were asking for (":amenu" does the right thing in
insert mode that you were doing manually with the ":map" commands, if
I'm not mistaken).

Anyway, since you already have it working I guess you can ignore all that... :-)

/Bjorn

Reply all
Reply to author
Forward
0 new messages