Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7744007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:40:18+00:00 2026-06-01T09:40:18+00:00

In SublimeText(2), when you press [ ctrl + shift + p ] (mac osx)

  • 0

In SublimeText(2), when you press [ctrl + shift + p] (mac osx) you are shown a scope of where your caret/cursor is in the source code at the given moment e.g.: entity.name.tag.inline.any.html meta.tag.inline.any.html text.html.basic

I am curious about what library or script is used to parse the document/file and create that scope string.

A sidenote: Typing view.syntax_name(view.sel()[0].b) into Sublime’s console will output the scope as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:40:19+00:00Added an answer on June 1, 2026 at 9:40 am

    well, the “libraries” that you are referring to are just the language grammars.

    Indeed, language grammars are just rule sets for divindg a document’s syntax into scopes.

    In other words, each rule in a grammar just assigns one or more elements of syntax to a scope.

    w/r/t the the actual parsing, for TextMate and Sublime Text, it is done by regular expressions.

    For instance, consider the python language grammar; As you know, when i put my cursor at the beginning of while, and do ctrl-shift-P (show scope), the scope will appear in the status bar:

    source.python.keyword.control.flow.python
    

    Again, this scope is defined in the python language grammar, so we can find the specific rule:

    { 
      match = '\b(elif|else|except|finally|for|if|try|while|with|break|continue|pass|raise|return|yield)\b';
    
      name = 'keyword.control.flow.python';
    }
    

    The first item, match is just the pattern that is passed into the parser.

    The second item, name is just the name given to that particular syntax element (i.e., the scope).

    Sublime Text 2 stores language grammars in the Packages directory with the extension tmLanguage as XML rather than JSON, so the rule above from the python language grammar looks like this in ST2:

    <dict>
        <key>
            match
        </key>
        <string>
            \b(elif|else|except|finally|for|if|try|while|with|break|....[truncated]
        </string>
    
        <key>
            name
        </key>
        <string>
            keyword.control.flow.python
        </string>
    </dict>
    

    So every rule in the grammar is wrapped in a pair of dict tags, and each rule’s regexp pattern is wrapped in string tags; ditto for its corresponding scope name.

    All of the language grammars are comprised entirely of these rules–with precisely this match/name (or pattern/scope) structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use Sublime Text 2 and want a Ruler to be shown in every
Visual Studio 2010 was projected to have a minimap feature for scrolling through code
Is there an emacs plugin which creates these nice vertical lines for the code
I've downloaded an editor of sublimetext and I want to know what GUI library
I did something wrong in Windows registry. When I installed SublimeText editor - http://www.sublimetext.com/
I just started using Sublime Text 2 on Mac. I also just started using
When running a python script on Sublime Text 2 (OSX), the python interpreter works
Right now in sublime text 2 when I start an if statement in Coldfusion
I've been using Sublime text 2 for the past few days, and I have
I've started using Sublime Text and it's great. But while editing Wix setup files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.