Atom keymap plus - module


Just wanted to share my latest atom module for atom plugins atom-keymap-plus.

The idea is to make it easier to use the same keymap for multiple plugins without them overlapping each other.

Keymap plus makes it possible to have the same keymap do different things. This is achieve by adding class names to the editor. That way you can use additional classes when assigning keymaps.

At the moment there is only one class function (setFileClasses()), that makes it posible to base your keymap on the active grammar like this:

    ".editor.javascript": {
        "cmd-alt-l": "jslint"
    ".editor.css": {
        "cmd-alt-l": "csslint"

Hope you like it, and please tell me if you miss other keymap related classes :blush:


What about using the lang attribute for grammars? I.e.

    ".editor[lang='javascript']": {
        "cmd-alt-l": "jslint"
    ".editor[lang='css']": {
        "cmd-alt-l": "csslint"

Though I don’t even know if that would work since MDN tells me that non-human languages are not valid lang values.

Just a thought…


maybe, but not sure what the idea would be? Atom is using classes to make keymaps, so way start using attributes?

And I don’t thinks its harder to read what the trigger is with .editor.javascript when with .editor[lang='javascript'] ??


lang defines “the language of the element, the language that non-editable elements are written in or the language that editable elements should be written in.”

I just thought it was a cool attribute that might fit the purpose better than a class :stuck_out_tongue: It doesn’t offer any functional benefit, only a semantic one.

Just something to think about. And thanks for the great plugin!


will keep that in mind, and if more ppl is thinking the same, we make the change :smiley:


I agree with @cbarrick for what its worth…

How do I scope a keymap to a grammar?

it’s worth a lot! I’m thinking of making an option param to select the way you like

setFileClasses({selector: 'class'});

setFileClasses({selector: 'attr'});


since atom 0.73.0 the event I was depending on editor:grammar-changed ain’t called that much so I had to add pane-container:active-pane-item-changed and destroyed.

Does anyone know a new event that is called every time the file type is defined?