Creating a keybinding for bold <strong> and italics <em>


How do you create a snippet that will wrap text inside <strong> or <em> for example? Then simply create a keybinding for it?

Unfortunately this question has been asked a lot.

Once upon a time, there use to be a plugin for this purpose. But, it’s outdated now.

Here is my unsuccessful attempt so far – adding a <strong> keybinding:

/* */

atom.commands.add 'atom-text-editor',
  'editor:wrap-with-strong': ->
    editor = atom.workspace.getActiveTextEditor()
    for selection in editor.getSelections()
      textToWrap = selection.getText()
// keymap.cson

  'alt-cmd-b': 'editor:wrap-with-strong'


ATOM must be restarted after adding the init coffee script and/or keymap. That’s the ticket!

#3 is run when Atom starts up, yes.