How to find the current scope


#1

Textmate has a shortcut to show the current scope. ^⇧⌘-P )
I was trying to make some snippets to work but couldn’t find the scope.


#2

This code does the trick:

atom.workspace.getActiveEditor().getGrammar().scopeName

You can see this code and get some inspiration.

https://github.com/atom/grammar-selector/blob/master/lib/grammar-status-view.coffee#L27


#3

You can also open the Console tab in Developer tools and press ⌘⌥P, that will log the current scope to the console.


#4

For the current version of Atom (I’m using 1.0.19), this is now:

atom.workspace.getActiveTextEditor().getGrammar().scopeName


#5

Thanks for the update