[null, null, null, {"document_url": "https://codedump.io/share/bpM9Q9NqNwUv/1/how-to-set-a-new-keybinding-in-atom-on-osx", "unformatted_src": "http://i.stack.imgur.com/mXrDi.png", "src": "http://i.stack.imgur.com/mXrDi.png", "formatted_filename": "mXrDi", "alt_text": "Atom Command Palette"}, null, {"document_url": "https://codedump.io/share/bpM9Q9NqNwUv/1/how-to-set-a-new-keybinding-in-atom-on-osx", "unformatted_src": "http://i.stack.imgur.com/8GklT.png", "src": "http://i.stack.imgur.com/8GklT.png", "formatted_filename": "GklT", "alt_text": "Key Binding Resolver"}, null]
j obe - 2 years ago 318

How to set a new keybinding in Atom on osx

I've started using Atom with a Macbook and I wanted to create a keybinding so that alt-up arrow would be page up and alt-down arrow for page down, I've tried a bunch of options and I'm not having much luck.

I'm not sure what the difference between


is and which one to use. I also have a package called emmet installed which is using alt-up and it always overrides what I'm trying, however I thought the keymap.cson file should override all 3rd party packages. Dan Lowe

The mini scope

The mini scope is for single-line inputs. For example, the "Find" or "Find in Project" panels use mini editors to accept input. The not([mini]) selector excludes those, so that your binding is only used in code editor windows/panes.

In this specific case, in practice it probably doesn't matter a lot, as the mini editors won't do anything with page-up or page-down anyway. But in general, I think it is better to scope the key bindings correctly instead of just making it global. It's a good habit.


You already have a good selector (atom-text-editor:not([mini])). In the comments you asked what other selectors are (in particular, atom-workspace and ::shadow). I don't have a great explanation of ::shadow but you might read a bit including here.

atom-text-editor is scoped to, as you'd expect, text editor panes. Whereas atom-workspace is a bit wider scope: it is scoped to the entire window, which might include things like the tree view, tabs, status bars, etc.

The ingredients of a key binding

In order to make a key binding, you need three things:

How to find Atom commands

Using the Command Palette

Every Atom command should be available in the Command Palette (CmdShiftP). In your case, you can trigger the palette and search for something like "page". You can see two matching commands, "Core: Page Up" and "Core: Page Down". To turn these into usable commands, you reformat them like so:

That leaves you with core:page-up and core:page-down.

Using the Key Binding Resolver

In some cases, you want to take a command already mapped to a key, and map it to another key. In those cases you can locate the command using Atom's Key Binding Resolver.

Activate the resolver by pressing Cmd.. This will open a panel at the bottom of your window and tell you what command each keypress is tied to. Pressing PageUp or PageDown will point you to the core:page-up and core:page-down commands. Press Cmd. again to deactivate the Key Binding Resolver.

Adding your keymap

In Atom's preferences, you can click "Open Config Folder" to open a new editor window with the config folder loaded. Open the keymap.cson file to add your new keymap.

Save the file and your keymap should go into effect immediately.

Email codedump link for How to set a new keybinding in Atom on osx

