How to get current … in Sublime Text
- Overview
- Audience
- Relevance
- Features
- Sublime Text console
- How to get current …
- 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.
- open Sublime Text
- open file whose
$parameter
you want to know - place your caret before symbol whose
$parameter
you want to knowCaution
Please, do not confuse caret and mouse pointer.
open Sublime Text console
- 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 directory — Data/Packages — path, where stored:
- “user packages” except “installed packages” in Sublime Text terminology
- User folder, where stored user settings
6.1.2. What should you do? ¶
6.1.3. Method ¶
sublime.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:
- it less simple
- in new versions of Sublime Text and/or operating systems paths may be change
- 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? ¶
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:
- color scheme — file, that design your Sublime Text syntaxes; it zone — area of your opened files
- 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? ¶
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? ¶
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.css | source.css | source |
text.html.basic source.css meta.property-list.css meta.property-name.css | text.html.basic | text |
kira.genius kira.error | kira.genius | kira |
6.5.2. What should you do? ¶
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:
- 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? ¶
6.6.3. Method ¶
view.scope_name(0).split()[0]