Atom editor: beware shift-cmd-W

Ever lost an unsaved file in Atom editor, because you accidentally pressed shift-cmd-W (close window without confirmation) instead of shift-alt-W (wrap selection in tag)?

Atom can restore a session when you close a previously saved file with unsaved edits, but it won’t (as far as my knowledge and agonizing experience go) restore a file that has not been saved before.

Solution: Add a custom keybinding to redefine the shift-cmd-W command.

  1. Atom→Keymap… to open keymap.cson.
  2. Add the following and save the file:
'body':
  'shift-cmd-W': 'core:close'

This basically duplicates the behavior of cmd-W for shift-cmd-W. Atom will nicely ask for confirmation before closing the file and sending your edits to Walhalla.

I use Atom to edit/write plain old HTML a lot, and I have no use for a command that would delete unsaved content without confirmation, so this works for me.

Should have done this way earlier.

Animated GIF of the process described above.

Happiness Rocketeering

When I’ll close my MacBook this evening, I’ll be closing a chapter in my working life. Today is my last day at Inpsyde, the WordPress agency I’ve had the pleasure working for since May 2013. By tomorrow morning, I’ll be jumping in my brand-new spacesuit and check in as a Happiness Rocketeer at WP Media, makers of WordPress products and services such as WP Rocket and Imagify.

Read on