How to get current … in Sublime Text

Page loading, please, little wait
Version 0.2.0
Posted — 2018-04-05T07:30:14+0300
Last modified — 2022-09-11T08:38:56+0300
You can comment this web-page
  1. Overview
  2. Audience
  3. Relevance
  4. Features
  5. Sublime Text console
    1. Console actions
  6. How to get current …
    1. Packages directory
      1. What is it?
      2. What should you do?
      3. Method
      4. Not recommended
    2. Syntax
      1. What is it?
      2. What should you do?
      3. Method
    3. Theme
      1. What is it?
      2. What should you do?
      3. Method
    4. Color scheme
      1. What is it?
      2. What should you do?
      3. Method
    5. Scope
      1. What is it?
      2. What should you do?
      3. Method
      4. Not recommended
    6. Syntax scope
      1. What is it?
      2. What should you do?
      3. Method
  7. External links

1. Overview

Article, how you can get some variable parameters for your Sublime Text. I wrote about the most common variable parameters, that you can found in my answers and comments in Stack Overflow.

2. Audience

Sublime Text users:

  • Inexperienced
  • Which help inexperienced users

3. Relevance

This article is relevant for April 2018. In the future, the data in this article may be obsolete.

4. Features

  • Data of this article cross platform. They are relevance for Windows, macOS and Linux users.

5. Sublime Text console

5.1. Console actions

  • $parameter — parameter, which you want to know.

Example: if you want to know your syntax, $parameter is Syntax; else theme, $parameter is Theme and so on.

  1. open Sublime Text
  2. open file whose $parameter you want to know
  3. place your caret before symbol whose $parameter you want to know

    Caution

    Please, do not confuse caret and mouse pointer.

  4. open Sublime Text console

  5. paste method from $parameter section to Sublime Text console input area → Enter

You should get console output, example:

6. How to get current …

6.1. Packages directory

6.1.1. What is it?

Packages directoryData/Packages — path, where stored:

  1. “user packages” except “installed packages” in Sublime Text terminology
  2. User folder, where stored user settings

6.1.2. What should you do?

Actions 1, 4, 5.

6.1.3. Method

sublime.packages_path()

Note

That get directory of “installed packages”, use this method:

sublime.installed_packages_path()

6.1.4. Not recommended

In some sources (example) you can read similar answers:

For Sublime 3, the locations are the following:

Windows: %APPDATA%Sublime Text 3,

OS X: ~/Library/Application Support/Sublime Text 3,

Linux: ~/.config/sublime-text-3.

I'm not recommend this, arguments:

  1. it less simple
  2. in new versions of Sublime Text and/or operating systems paths may be change
  3. it doesn’t take portable Sublime Text on Windows

6.2. Syntax

6.2.1. What is it?

6.2.2. What should you do?

Actions 1, 2, 4, 5.

6.2.3. Method

view.settings().get('syntax')

6.3. Theme

6.3.1. What is it?

Please, do not confuse theme and color scheme:

  1. color scheme — file, that design your Sublime Text syntaxes; it zone — area of your opened files
  2. theme — file, that design your Sublime Text UI; almost everyone else, that not highlight color scheme

In image below:

  • color scheme design area in a pink rectangle
  • theme — another area, blue rectangle

Hint

Also, some parameters has in Preferences.sublime-settings and stTheme files. stTheme highlight and stylize regular expressions and another elements in input areas of your “Find”, “Find in Files” and “Replace panels”.

6.3.2. What should you do?

Actions 1, 2, 4, 5.

6.3.3. Method

view.settings().get('theme')

6.4. Color scheme

6.4.1. What is it?

6.4.2. What should you do?

Actions 1, 2, 4, 5.

6.4.3. Method

view.settings().get('color_scheme')

Hint

You can get your another settings, use view.settings().get(). Example: that get your current font face, you need view.settings().get('font_face').

6.5. Scope

Caution

“Scope”, “syntax scope”, “syntax type scope” unconventional, not official terms. Please, read links below for more detailed information.

6.5.1. What is it?

“scope”“syntax scope”“syntax type scope”
source.css meta.property-list.css meta.property-name.css support.type.property-name.csssource.csssource
text.html.basic source.css meta.property-list.css meta.property-name.csstext.html.basictext
kira.genius kira.errorkira.geniuskira

6.5.2. What should you do?

Actions 1, 2, 3, 4, 5.

6.5.3. Method

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

6.5.4. Not recommended

In some sources (example) you can read similar answers:

Windows — Ctrl+Alt+Shift+P,

macOS — Ctrl+Shift+P.

I not recommend it, arguments:

  1. Hotkeys conflict; one or more your plugins may use same hotkeys.

6.6. Syntax scope

6.6.1. What is it?

Syntax scope — for syntax: part of any scope before first space symbol. Details read above.

6.6.2. What should you do?

Actions 1, 2, 4, 5.

6.6.3. Method

view.scope_name(0).split()[0]

7. External links

Share

You can share this page on social networks using the AddToAny social buttons widget on the side of the page

Subcsribe

You can subscribe to the Atom or RSS feeds of all site materials and any of its categories and tags. To subscribe, you need to install any feed reader software. Choose subscriptions to Atom if preferable for you reading articles in your feed reader. Choose subscriptions to RSS feeds if more convenient for you to fully read articles in the browser; your feed reader will display solely the article abstracts.

Report a typo or error

(Solely for desktop, not mobile devices). If you see a typo, inaccuracy or error on this page, please report it using typo-reporter: select text with a typo/mistake → press Ctrl+Enter (⌘Enter for Mac) → write your comment → Send.

Edit page

You can edit this page yourself on GitHub and send pull request.

Comment

For any questions please contact via utterances comment widget below. Please be polite and constructive.

To leave a comment, you need to be registered with GitHub. When writing comments, use Markdown syntax.

Once sended, your comment should appear at the top of the list of issues for this site. Notification of a reply to your comment should be sent to the email associated with your GitHub account.

You can also write and send your message use GitHub Issues directly.

Работайте над собой