Emmet:toggle-comment keyboard shortcut - keymap.cson not overriding


#1

os: ubuntu 16.04
atom: 1.8.0

I am trying to create a new shortcut for toggling emmet comments using ctrl-space.

So far I have:

  • Opened settings/keybindings
  • Searched for the keybinding I want to use for this shortcut (ctrl-space)
  • Copied the shortcut using the clipboard icon - currently set to autocomplete-plus:activate
  • in keymap.cson, I pasted the shortcut command:
    'atom-text-editor':
        'ctrl-space': 'autocomplete-plus:activate'
  • I then edited the shortcut from autocomplete-plus:activate to emmet:toggle-comment
  • I then save my changes

So far so good?

Ok, so when I move to a file and inspect the key-binding-resolver, ctrl-space is still pointing to autocomplete-plus:activate (highlighted in green) and my new shortcut for emmet:toggle-comment is underneath it (highlighted in grey). Both shortcuts have ticks next to them (not crosses).

I undid all my previous edits, then tried a different approach:

  • Opened settings/keybindings
  • Searched for emmet:toggle-comment
  • Copied the shortcut using the clipboard icon
  • in keymap.cson, I have pasted the shortcut command:
    'atom-pane atom-text-editor:not([mini])':
        'ctrl-shift-/': 'emmet:toggle-comment'
  • I then edited the shortcut from ctrl-shift-/ to ctrl-space
  • I then save my changes

Same result! :frowning:

Any advice?

Thanks in advance!


#2

It’s ok - I just figured out I didn’t enable emmet comments in the emmet package settings! :flushed:


#3

If you’re overriding an existing shortcut, you have to unbind the existing one first:

'atom-text-editor':
  'ctrl-space': 'unset!'
  'ctrl-space': 'emmet:toggle-comment'

#4

You don’t need to unbind the existing one first. Simply mapping a new command to the existing keybinding will work.