15

I'm trying to define some snippets for editing Markdown, but I can't get them to trigger. I have tried using source.markdown, text.markdown and markdown as the scope, but none of them work. If I remove the scope constraint, the snippet works.

How do I figure out what scope to use?

Hubro
  • 5,716
  • 14
  • 61
  • 87

2 Answers2

32

To determine the current scope under your cursor, Ctrl+Alt+Shift+P on Windows and Linux does the trick, Ctrl+Shift+P on a Mac.

Alternatively, run the following in the Sublime console:

view.scope_name(view.sel()[0].begin())

To bring up the console on Windows, press Ctrl+'

awatts
  • 506
  • 4
  • 5
  • Marking this as accepted as it's technically a better answer (doesn't require a plugin) – Hubro Sep 23 '17 at 05:05
  • 1
    Ctrl+Alt+Shift+P works on Linux as well. – Nishant Jan 25 '19 at 19:47
  • Ctrl + Alt + Shift + P won't work for me in Linux Ubuntu 20.04 for some reason, so I created a custom keyboard shortcut to Ctrl + Alt + Shift + S, and that works fine now. See my question here: [Ctrl + Alt + Shift + P doesn't work to "Show Scope Name" in Sublime Text 4 in Linux](https://superuser.com/q/1711933/425838) – Gabriel Staples Mar 21 '22 at 06:22
2

The scope for Markdown is text.html.markdown. I think there are several packages that help you identify the current scope, ScopeAlways is one of them.

idleberg
  • 1,342
  • 1
  • 11
  • 17
  • Nice, that worked! I'm confused though. If `text.html.markdown` works, shouldn't just `markdown` work too? I guess the scopes don't work the way I thought they did. – Hubro Dec 05 '14 at 08:20
  • ScopeAlways works flawlessly by the way, couldn't ask for more. – Hubro Dec 05 '14 at 08:22
  • 1
    The scope gets more specific with each appended child. Snippets in the scope `text` will work for all child scopes, e.g. `text.html` and `text.html.markdown`, but the latter will not work in any of its parents. You can also exclude certain child scopes, e.g. `text.html -text.html.markdown`. – idleberg Dec 05 '14 at 08:47
  • I thought it got more specific for each *prepended* child. Thanks for explaining :) – Hubro Dec 05 '14 at 08:48