How do you run a command from an installed package from


I feel like this should pretty easy to do, but, as the title says, how do you run a registered command from a package you have installed in The situation is I have vim-mode installed, and want to make alt-o map to the command “vim-mode:insert-below-with-newline”, and then do “vim-mode:reset-command-mode”. How would I create a command to do this? Right now I have the following:

    atom.commands.add 'atom-text-editor',
      'custom:newline-no-insert': (event) ->

P.S. Pardon my inexperience, I couldn’t find anything on this in the API and I’m (obviously) pretty new to the Atom customization game.


My guess is that it doesn’t work because you’re dispatching the commands on the workspace while vim-mode triggers its commands on text editors.

Maybe you can try this instead:

atom.commands.add 'atom-text-editor',
  "custom:newline-no-insert": (event) ->
    editorElement = atom.views.getView(atom.workspace.getActiveTextEditor())
    atom.commands.dispatch(editorElement, 'vim-mode:insert-below-with-newline')
    atom.commands.dispatch(editorElement, 'vim-mode:reset-command-mode')


Thanks man, it worked!


That totally worked.

In my case I wanted to built a keymap that allowed me to save and exit from insert mode (using the in vim-mode package) by pressing j-k.

I did it with the following:

// in the
atom.commands.add 'atom-text-editor',
  'custom:save-and-normal-mode': (event) ->
    editor = atom.workspace.getActivePane()
    editorElement = atom.views.getView(atom.workspace.getActiveTextEditor())
    atom.commands.dispatch(editorElement, 'vim-mode:activate-normal-mode')

// in the keymap.cson 
  'j k': 'custom:save-and-normal-mode'