How to add menu separators?


#1

Hi,

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?


#2

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.contextMenu.add
  'atom-text-editor': [{type: 'separator'}, {label: 'Show in Explorer', command: 'atom-text-editor:show-in-file-manager'}]

#3

Great! It works perfectly… Thanks :+1: