How to add menu separators?



I’m trying to add a context menu on my init.cson, with a separator before it (or surrounded). I looked at API Documentation that says: If you want to create a separator, provide an item with type: ‘separator’ and no other keys, and made this:

atom.contextMenu.add {
  'atom-text-editor': [{type: 'separator'}]
  'atom-text-editor': [{label: 'Show in Explorer', command: 'atom-text-editor:show-in-file-manager'}]

The Show in Explorer is added, but no separator…

I also tried using label: '-', but didn’t work.

Any idea?


It doesn’t work because you specify the 'atom-text-editor' key twice in the same object, so the first one gets overwritten. Put the menuitems in the same array:

  'atom-text-editor': [{type: 'separator'}, {label: 'Show in Explorer', command: 'atom-text-editor:show-in-file-manager'}]


Great! It works perfectly… Thanks :+1: