atom keymap: how to insert space for alt-space on mac

2

1

As per How to disable the Option-Space key combination for non-breaking spaces? I want something like this in my keymap.cson:

'.platform-darwin .editor':
  'alt-space': 'editor:space'

It half works: it stops the non-breaking-space being inserted, but doesn't insert a normal space instead.

I couldn't find a list of commands for atom in the docs or source code. Do I have to define a new command? That seems like overkill?

nruth

Posted 2015-06-10T23:46:27.130

Reputation: 123

Thanks a lot for the snippet! For me it was important just to avoid putting NO-BREAK SPACE (U+00A0) in my files. – mik01aj – 2015-06-11T09:53:19.333

Answers

4

The problem with your keymap entry is that the editor:space command does not exist. (You can search for commands using command-shift-p)

Indeed, you need to create your own command in your init.coffee like this:

atom.commands.add 'atom-text-editor', 'custom:space', () ->
    editor = atom.workspace.getActiveTextEditor()
    editor.insertText(' ')

And then use this command instead of editor:space in your keymap.cson:

'.platform-darwin .editor':
  'alt-space': 'custom:space'

Jesper Oskarsson

Posted 2015-06-10T23:46:27.130

Reputation: 56