Replace deprecated code in


A long, long time ago I was given advice on how to set up a built-in shortcut for simple things like adding a non-breaking space to html.

So I have

atom.workspaceView.command 'editor:insert-nbsp', ->
atom.workspace.getActiveEditor()?.insertText(' ')

Which is apparently deprecated. What’s the modern way to do this sort of thing?


I am just typing this in browser window without testing, but I think you want:

atom.commands.add 'atom-text-editor',
  'editor:insert-nbsp': (event) ->
    editor = @getModel()
    editor.insertText(' ')

See examples here for more info:


I just tested @jessegrosjean’s solution and it worked.


Yes, it did. Thanks. Now only 3rd party items are flagged by Deprecation Cop.

I also needed to change my keymap from





I suggest you should use atom-text-editor:not([mini]) instead.