Prevent cmd-w from closing a pane?


#1

Does anybody know if there’s a way to prevent the cmd+w keybinding from closing a pane when no tabs are open?

I like to configure my editor with two panes side-by-side and keep it that way. It’s frustrating when an extra cmd+w accidentally closes the pane and I have to configure it again. Not the end of the world, but just annoying.

Thanks


#2

You could map Cmd+W to a different command that only closes tabs instead of panes. By default it is mapped to core:close. You can check out the the-closer package to see one approach to changing the behavior of core:close.


#3

I’m new to Atom, but I think you just want to uncheck ‘Destroy Empty Panes’ option on the main settings screen:


#4

Hehe … oh yeah, there’s that too :blush:


#5

Thanks for the suggestion. I do have that unchecked, but that only prevents the pane from being destroyed when the last file is closed. If you hit cmd+w again, it still closes the pane.

@leedohm thanks for the suggestion on remapping cmd+w but I have not been able to do that successfully yet. Mainly because I haven’t taken time to write a command :slight_smile:


#6

I unchecked the “Destroy Empty Panes” setting that @pascalpp mentioned and then added this to my init.coffee:

atom.commands.add 'atom-workspace',
  'custom:close': ->
    atom.workspace.destroyActivePaneItem()

and then mapped Cmd+W to custom:close instead of core:close. That seems to have done it. Let me know if it works for you.


#7

To be honest, I would expect “Destroy Empty Panes” to also not destroy on cmd+w (or ctrl+w on linux). To me this kind of feels like a user experience bug. If I close the tab - however I decide to do that - the pane should stay open.

Thanks for the hack solution @leedohm, but would this qualify as something to report as a bug fix?