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
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
>> 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
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
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
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