Documentation TOP API Reference
- Example Plugins
- Plugin Lifecycle
- Threading
- Units and Coordinates
- Types
sublimeWindowEditRegionHistoricPositionTextChangeSelectionSheetTextSheetImageSheetHtmlSheetContextStackFrameViewBufferSettingsPhantomPhantomSetHtmlCompletionListCompletionItemSyntaxQuickPanelItemListInputItemSymbolRegionSymbolLocationsublime_pluginCommandInputHandlerBackInputHandlerTextInputHandlerListInputHandlerCommandApplicationCommandWindowCommandTextCommandEventListenerViewEventListenerTextChangeListener
General Information
Example Plugins
Several pre-made plugins come with Sublime Text, you can find them in the Default package:
Packages/Default/exec.pyUses phantoms to display errors inlinePackages/Default/font.pyShows how to work with settingsPackages/Default/goto_line.pyPrompts the user for input, then updates the selectionPackages/Default/mark.pyUses add_regions() to add an icon to the gutterPackages/Default/show_scope_name.pyUses a popup to show the scope names at the caretPackages/Default/arithmetic.pyAccepts an input from the user when run via the Command Palette
Plugin Lifecycle
At importing time, plugins may not call any API functions, with the exception of:
4081
- sublime.packages_path()
4081
- sublime.installed_packages_path()
4081
- sublime.cache_path()
4081
<4171
If a plugin defines a module level function plugin_loaded(), this will be
called when the API is ready to use. Plugins may also define
plugin_unloaded(), to get notified just before the plugin is unloaded.
Threading
All API functions are thread-safe, however keep in mind that from the perspective of code running in an alternate thread, application state will be changing while the code is running.
Units and Coordinates
API functions that accept or return coordinates or dimensions do so using device-independent pixel (dip) values. While in some cases these will be equivalent to device pixels, this is often not the case. Per the CSS specification, minihtml treats the px unit as device-independent.
Types
sublime.DIP = float : Represents a device-independent pixel position.
sublime.Vector = tuple[DIP, DIP] : Represents a X and Y coordinate.
sublime.Point = int : Represents the offset from the beginning of the editor buffer.
sublime.Value = bool | str | int | float | list[Value] | dict[str, Value] | None : A JSON-equivalent value.
sublime.CommandArgs = dict[str, Value] | None
: The arguments to a command may be None or a dict of str keys.
sublime.Kind = tuple[KindId, str, str]
: Metadata about the kind of a symbol, CompletionItem, QuickPanelItem or
ListInputItem. Controls the color and letter shown in the “icon” presented
to the left of the item.
sublime.Event = dict
: Contains information about a user’s interaction with a menu, command palette
selection, quick panel selection or HTML document. The follow methods are
used to signal that an event dict is desired:
- Commands may opt-in to receive an arg named `event` by implementing the
method `want_event(self)` and returning `True`.
- A call to [`show_quick_panel()`](#sublime.Window.show_quick_panel) may opt-in to receive a second arg to the
`on_done` callback by specifying the flag
[`QuickPanelFlags.WANT_EVENT`](#sublime.QuickPanelFlags.WANT_EVENT).
4096
- [`ListInputHandler`](#sublime_plugin.ListInputHandler) classes may opt-in to receive a second arg to the
[`validate()`](#sublime_plugin.CommandInputHandler.validate) and [`confirm()`](#sublime_plugin.CommandInputHandler.confirm) methods by by implementing the method
[`want_event()`](#sublime_plugin.CommandInputHandler.want_event) and
returning `True`.
4096
The dict may contain zero or more of the following keys, based on the user
interaction:
“x”: float
: The X mouse position when a user clicks on a menu, or in a minihtml
document.
“y”: float
: The Y mouse position when a user clicks on a menu, or in a minihtml document.
“modifier\_keys”: dict
4096
: Can have zero or more of the following keys:
- `“primary”` - indicating **Ctrl** (Windows/Linux) or **Cmd**
(Mac) was pressed
- `“ctrl”` - indicating **Ctrl** was pressed
- `“alt”` - indicating **Alt** was pressed
- `“altgr”` - indicating **AltGr** was pressed (Linux only)
- `“shift”` - indicating **Shift** was pressed
- `“super”` - indicating **Win** (Windows/Linux) or **Cmd**
(Mac) was pressed
Present when the user selects an item from a quick panel, selects an item
from a [`ListInputHandler`](#sublime_plugin.ListInputHandler), or clicks a link in a [minihtml](https://www.sublimetext.com/docs/minihtml.html)
document.
sublime.CompletionValue = str | tuple[str, str] | CompletionItem : Represents an available auto-completion item. completion values may be of several formats. The term trigger refers to the text matched against the user input, replacement is what is inserted into the view if the item is selected. An annotation is a unicode string hint displayed to the right-hand side of the trigger.
- `str`:
A string that is both the trigger and the replacement:
```
[
"method1()",
"method2()",
]
```
- 2-element `tuple` or `list`:
A pair of strings - the trigger and the replacement:
```
[
["me1", "method1()"],
["me2", "method2()"]
]
```
If a t is present in the trigger, all subsequent text is treated as an
annotation:
```
[
["me1\tmethod", "method1()"],
["me2\tmethod", "method2()"]
]
```
The replacement text may contain dollar-numeric fields such as a snippet does, e.g. `$0`, `$1`:
```
[
["fn", "def ${1:name}($2) { $0 }"],
["for", "for ($1; $2; $3) { $0 }"]
]
```
- [`CompletionItem`](#sublime.CompletionItem) object
An object containing trigger, replacement, annotation, and kind metadata:
```
[
sublime.CompletionItem(
"fn",
annotation="def",
completion="def ${1:name}($2) { $0 }",
completion_format=sublime.COMPLETION_FORMAT_SNIPPET,
kind=sublime.KIND_SNIPPET
),
sublime.CompletionItem(
"for",
completion="for ($1; $2; $3) { $0 }",
completion_format=sublime.COMPLETION_FORMAT_SNIPPET,
kind=sublime.KIND_SNIPPET
),
]
```
4050
sublime Module
exception sublime.FileTooLargeError
: Bases: FileNotFoundError
Raised when a resource exceeds file size limits.
class sublime.HoverZone 4132 3.8
: Bases: IntEnum
A zone in an open text sheet where the mouse may hover.
See [`EventListener.on_hover`](#sublime_plugin.EventListener.on_hover) and [`ViewEventListener.on_hover`](#sublime_plugin.ViewEventListener.on_hover).
For backwards compatibility these values are also available outside this
enumeration with a `HOVER_` prefix.
TEXT = 1
: The mouse is hovered over the text.
GUTTER = 2
: The mouse is hovered over the gutter.
MARGIN = 3
: The mouse is hovered in the white space to the right of a line.
class sublime.NewFileFlags 4132 3.8
: Bases: IntFlag
Flags for creating/opening files in various ways.
See [`Window.new_html_sheet`](#sublime.Window.new_html_sheet), [`Window.new_file`](#sublime.Window.new_file) and [`Window.open_file`](#sublime.Window.open_file).
For backwards compatibility these values are also available outside this
enumeration (without a prefix).
NONE = 0
ENCODED\_POSITION = 1
: Indicates that the file name should be searched for a `:row` or
`:row:col` suffix.
TRANSIENT = 4
: Open the file as a preview only: it won’t have a tab assigned it until
modified.
FORCE\_GROUP = 8
: Don’t select the file if it is open in a different group. Instead make a new
clone of that file in the desired group.
SEMI\_TRANSIENT = 16
4096
: If a sheet is newly created, it will be set to semi-transient.
Semi-transient sheets generally replace other semi-transient sheets. This
is used for the side-bar preview. Only valid with [`ADD_TO_SELECTION`](#sublime.NewFileFlags.ADD_TO_SELECTION) or
[`REPLACE_MRU`](#sublime.NewFileFlags.REPLACE_MRU).
ADD\_TO\_SELECTION = 32
4050
: Add the file to the currently selected sheets in the group.
REPLACE\_MRU = 64
4096
: Causes the sheet to replace the most-recently used sheet in the current sheet selection.
CLEAR\_TO\_RIGHT = 128
4100
: All currently selected sheets to the right of the most-recently used sheet
will be unselected before opening the file. Only valid in combination with
[`ADD_TO_SELECTION`](#sublime.NewFileFlags.ADD_TO_SELECTION).
FORCE\_CLONE = 256
: Don’t select the file if it is open. Instead make a new clone of that file in the desired
group.
class sublime.FindFlags 4132 3.8
: Bases: IntFlag
Flags for use when searching through a [`View`](#sublime.View).
See [`View.find`](#sublime.View.find) and [`View.find_all`](#sublime.View.find_all).
For backwards compatibility these values are also available outside this
enumeration (without a prefix).
NONE = 0
LITERAL = 1
: Whether the find pattern should be matched literally or as a regex.
IGNORECASE = 2
: Whether case should be considered when matching the find pattern.
WHOLEWORD = 4
4149
: Whether to only match whole words.
REVERSE = 8
4149
: Whether to search backwards.
WRAP = 16
4149
: Whether to wrap around once the end is reached.
class sublime.QuickPanelFlags 4132 3.8
: Bases: IntFlag
Flags for use with a quick panel.
See [`Window.show_quick_panel`](#sublime.Window.show_quick_panel).
For backwards compatibility these values are also available outside this
enumeration (without a prefix).
NONE = 0
MONOSPACE\_FONT = 1
: Use a monospace font.
KEEP\_OPEN\_ON\_FOCUS\_LOST = 2
: Keep the quick panel open if the window loses input focus.
WANT\_EVENT = 4
4096
: Pass a second parameter to the `on_done` callback, a [`Event`](#sublime.Event).
class sublime.PopupFlags 4132 3.8
: Bases: IntFlag
Flags for use with popups.
See [`View.show_popup`](#sublime.View.show_popup).
For backwards compatibility these values are also available outside this
enumeration (without a prefix).
NONE = 0
COOPERATE\_WITH\_AUTO\_COMPLETE = 2
: Causes the popup to display next to the auto complete menu.
HIDE\_ON\_MOUSE\_MOVE = 4
: Causes the popup to hide when the mouse is moved, clicked or scrolled.
HIDE\_ON\_MOUSE\_MOVE\_AWAY = 8
: Causes the popup to hide when the mouse is moved (unless towards the popup),
or when clicked or scrolled.
KEEP\_ON\_SELECTION\_MODIFIED = 16
4057
: Prevent the popup from hiding when the selection is modified.
HIDE\_ON\_CHARACTER\_EVENT = 32
4057
: Hide the popup when a character is typed.
class sublime.RegionFlags 4132 3.8
: Bases: IntFlag
Flags for use with added regions. See [`View.add_regions`](#sublime.View.add_regions).
For backwards compatibility these values are also available outside this
enumeration (without a prefix).
NONE = 0
DRAW\_EMPTY = 1
: Draw empty regions with a vertical bar. By default, they aren’t drawn at all.
HIDE\_ON\_MINIMAP = 2
: Don’t show the regions on the minimap.
DRAW\_EMPTY\_AS\_OVERWRITE = 4
: Draw empty regions with a horizontal bar instead of a vertical one.
PERSISTENT = 16
: Save the regions in the session.
DRAW\_NO\_FILL = 32
: Disable filling the regions, leaving only the outline.
HIDDEN = 128
: Don’t draw the regions.
DRAW\_NO\_OUTLINE = 256
: Disable drawing the outline of the regions.
DRAW\_SOLID\_UNDERLINE = 512
: Draw a solid underline below the regions.
DRAW\_STIPPLED\_UNDERLINE = 1024
: Draw a stippled underline below the regions.
DRAW\_SQUIGGLY\_UNDERLINE = 2048
: Draw a squiggly underline below the regions.
NO\_UNDO = 8192
class sublime.QueryOperator 4132 3.8
: Bases: IntEnum
Enumeration of operators able to be used when querying contexts.
See [`EventListener.on_query_context`](#sublime_plugin.EventListener.on_query_context) and
[`ViewEventListener.on_query_context`](#sublime_plugin.ViewEventListener.on_query_context).
For backwards compatibility these values are also available outside this
enumeration with a `OP_` prefix.
EQUAL = 0
NOT\_EQUAL = 1
REGEX\_MATCH = 2
NOT\_REGEX\_MATCH = 3
REGEX\_CONTAINS = 4
NOT\_REGEX\_CONTAINS = 5
class sublime.PointClassification 4132 3.8
: Bases: IntFlag
Flags that identify characteristics about a [`Point`](#sublime.Point) in a text sheet. See
[`View.classify`](#sublime.View.classify).
For backwards compatibility these values are also available outside this
enumeration with a `CLASS_` prefix.
NONE = 0
WORD\_START = 1
: The point is the start of a word.
WORD\_END = 2
: The point is the end of a word.
PUNCTUATION\_START = 4
: The point is the start of a sequence of punctuation characters.
PUNCTUATION\_END = 8
: The point is the end of a sequence of punctuation characters.
SUB\_WORD\_START = 16
: The point is the start of a sub-word.
SUB\_WORD\_END = 32
: The point is the end of a sub-word.
LINE\_START = 64
: The point is the start of a line.
LINE\_END = 128
: The point is the end of a line.
EMPTY\_LINE = 256
: The point is an empty line.
class sublime.AutoCompleteFlags 4132 3.8
: Bases: IntFlag
Flags controlling how asynchronous completions function. See
[`CompletionList`](#sublime.CompletionList).
For backwards compatibility these values are also available outside this
enumeration (without a prefix).
NONE = 0
INHIBIT\_WORD\_COMPLETIONS = 8
: Prevent Sublime Text from showing completions based on the contents of the
view.
INHIBIT\_EXPLICIT\_COMPLETIONS = 16
: Prevent Sublime Text from showing completions based on
.sublime-completions files.
DYNAMIC\_COMPLETIONS = 32
4057
: If completions should be re-queried as the user types.
INHIBIT\_REORDER = 128
4074
: Prevent Sublime Text from changing the completion order.
class sublime.DialogResult 4132 3.8
: Bases: IntEnum
The result from a *yes / no / cancel* dialog. See [`yes_no_cancel_dialog`](#sublime.yes_no_cancel_dialog).
For backwards compatibility these values are also available outside this
enumeration with a `DIALOG_` prefix.
CANCEL = 0
YES = 1
NO = 2
class sublime.PhantomLayout 4132 3.8
: Bases: IntEnum
How a [`Phantom`](#sublime.Phantom) should be positioned. See [`PhantomSet`](#sublime.PhantomSet).
For backwards compatibility these values are also available outside this
enumeration with a `LAYOUT_` prefix.
INLINE = 0
: The phantom is positioned inline with the text at the beginning of its
[`Region`](#sublime.Region).
BELOW = 1
: The phantom is positioned below the line, left-aligned with the beginning of
its [`Region`](#sublime.Region).
BLOCK = 2
: The phantom is positioned below the line, left-aligned with the beginning of
the line.
class sublime.KindId 4132 3.8
: Bases: IntEnum
For backwards compatibility these values are also available outside this
enumeration with a `KIND_ID_` prefix.
AMBIGUOUS = 0
KEYWORD = 1
TYPE = 2
FUNCTION = 3
NAMESPACE = 4
NAVIGATION = 5
MARKUP = 6
VARIABLE = 7
SNIPPET = 8
COLOR\_REDISH = 9
COLOR\_ORANGISH = 10
COLOR\_YELLOWISH = 11
COLOR\_GREENISH = 12
COLOR\_CYANISH = 13
COLOR\_BLUISH = 14
COLOR\_PURPLISH = 15
COLOR\_PINKISH = 16
COLOR\_DARK = 17
COLOR\_LIGHT = 18
sublime.KIND_AMBIGUOUS: Kind = (KindId.AMBIGUOUS, '', '') 4052
sublime.KIND_KEYWORD: Kind = (KindId.KEYWORD, '', '') 4052
sublime.KIND_TYPE: Kind = (KindId.TYPE, '', '') 4052
sublime.KIND_FUNCTION: Kind = (KindId.FUNCTION, '', '') 4052
sublime.KIND_NAMESPACE: Kind = (KindId.NAMESPACE, '', '') 4052
sublime.KIND_NAVIGATION: Kind = (KindId.NAVIGATION, '', '') 4052
sublime.KIND_MARKUP: Kind = (KindId.MARKUP, '', '') 4052
sublime.KIND_VARIABLE: Kind = (KindId.VARIABLE, '', '') 4052
sublime.KIND_SNIPPET: Kind = (KindId.SNIPPET, 's', 'Snippet') 4052
class sublime.SymbolSource 4132 3.8
: Bases: IntEnum
See [`Window.symbol_locations`](#sublime.Window.symbol_locations).
For backwards compatibility these values are also available outside this
enumeration with a `SYMBOL_SOURCE_` prefix.
ANY = 0
4085
: Use any source - both the index and open files.
INDEX = 1
4085
: Use the index created when scanning through files in a project folder.
OPEN\_FILES = 2
4085
: Use the open files, unsaved or otherwise.
class sublime.SymbolType 4132 3.8
: Bases: IntEnum
See [`Window.symbol_locations`](#sublime.Window.symbol_locations) and [`View.indexed_symbol_regions`](#sublime.View.indexed_symbol_regions).
For backwards compatibility these values are also available outside this
enumeration with a `SYMBOL_TYPE_` prefix.
ANY = 0
4085
: Any symbol type - both definitions and references.
DEFINITION = 1
4085
: Only definitions.
REFERENCE = 2
4085
: Only references.
class sublime.CompletionFormat 4132 3.8
: Bases: IntEnum
The format completion text can be in. See [`CompletionItem`](#sublime.CompletionItem).
For backwards compatibility these values are also available outside this
enumeration with a `COMPLETION_FORMAT_` prefix.
TEXT = 0
4050
: Plain text, upon completing the text is inserted verbatim.
SNIPPET = 1
4050
: A snippet, with `$` variables. See also
[`CompletionItem.snippet_completion`](#sublime.CompletionItem.snippet_completion).
COMMAND = 2
4050
: A command string, in the format returned by [`format_command()`](#sublime.format_command). See also
[`CompletionItem.command_completion()`](#sublime.CompletionItem.command_completion).
sublime.version() → str : Returns: : The version number.
sublime.platform() → Literal['osx', 'linux', 'windows'] : Returns: : The platform which the plugin is being run on.
sublime.arch() → Literal['x32', 'x64', 'arm64'] : Returns: : The CPU architecture.
sublime.channel() → Literal['dev', 'stable'] : Returns: : The release channel of this build of Sublime Text.
sublime.executable_path() → str : This may be called at import time.
4081
Returns:
: The path to the main Sublime Text executable.
sublime.executable_hash() → tuple[str, str, str] : This may be called at import time.
4081
Returns:
: A tuple uniquely identifying the installation of Sublime Text.
sublime.packages_path() → str : This may be called at import time.
4081
Returns:
: The path to the “Packages” folder.
sublime.installed_packages_path() → str : This may be called at import time.
4081
Returns:
: The path to the “Installed Packages” folder.
sublime.cache_path() → str : This may be called at import time.
4081
Returns:
: The path where Sublime Text stores cache files.
sublime.lib_path() → str 4201
: Returns: : The path to the “Lib” folder.
sublime.status_message(msg: str) : Show a message in the status bar.
sublime.error_message(msg: str) : Display an error dialog.
sublime.message_dialog(msg: str) : Display a message dialog.
sublime.ok_cancel_dialog(msg: str, ok_title='', title='') → bool : Show a ok / cancel question dialog.
Parameters:
: `msg`
: The message to show in the dialog.
`ok_title`
: Text to display on the *ok* button.
`title`
4099
: Title for the dialog. Windows only.
Returns:
: Whether the user pressed the *ok* button.
sublime.yes_no_cancel_dialog(msg: str, yes_title='', no_title='', title='') → DialogResult : Show a yes / no / cancel question dialog.
Parameters:
: `msg`
: The message to show in the dialog.
`yes_title`
: Text to display on the *yes* button.
`no_title`
: Text to display on the *no* button.
`title`
4099
: Title for the dialog. Windows only.
sublime.open_dialog(callback: Callable[[str | list[str] | None], None], file_types: list[tuple[str, list[str]]] = [], directory: str | None = None, multi_select=False, allow_folders=False) 4075
: Show the open file dialog.
Parameters:
: `callback`
: Called with selected path(s) or `None` once the dialog is closed.
`file_types`
: A list of allowed file types, consisting of a description
and a list of allowed extensions.
`directory`
: The directory the dialog should start in. Will use the
virtual working directory if not provided.
`multi_select`
: Whether to allow selecting multiple files. When `True`
the callback will be called with a list.
`allow_folders`
: Whether to also allow selecting folders. Only works on
macOS. If you only want to select folders use
[`select_folder_dialog`](#sublime.select_folder_dialog).
sublime.save_dialog(callback: Callable[[str | None], None], file_types: list[tuple[str, list[str]]] = [], directory: str | None = None, name: str | None = None, extension: str | None = None) 4075
: Show the save file dialog
Parameters:
: `callback`
: Called with selected path or `None` once the dialog is closed.
`file_types`
: A list of allowed file types, consisting of a description
and a list of allowed extensions.
`directory`
: The directory the dialog should start in. Will use the
virtual working directory if not provided.
`name`
: The default name of the file in the save dialog.
`extension`
: The default extension used in the save dialog.
sublime.select_folder_dialog(callback: Callable[[str | list[str] | None], None], directory: str | None = None, multi_select=False) 4075
: Show the select folder dialog.
Parameters:
: `callback`
: Called with selected path(s) or `None` once the dialog is closed.
`directory`
: The directory the dialog should start in. Will use the
virtual working directory if not provided.
`multi_select`
: Whether to allow selecting multiple files. When `True`
the callback will be called with a list.
sublime.choose_font_dialog(callback: Callable[[Value], None], default: dict[str, Value] | None = None) 4157
: Show a dialog for selecting a font.
Parameters:
: `callback`
: Called with the font options, matching the format used in
settings (eg. `{ “font_face”: “monospace” }`). May be
called more than once, or will be called with `None` if
the dialog is cancelled.
`default`
: The default values to select/return. Same format as the
argument passed to [`callback`](https://docs.python.org/3/glossary.html#term-callback).
sublime.run_command(cmd: str, args: CommandArgs = None)
: Run the named ApplicationCommand.
sublime.format_command(cmd: str, args: CommandArgs = None) → str 4075
: Create a “command string” from a cmd name and args arguments. This
is used when constructing a command-based CompletionItem.
sublime.html_format_command(cmd: str, args: CommandArgs = None) → str 4075
: Returns: : An escaped “command string” for usage in HTML popups and sheets.
sublime.command_url(cmd: str, args: CommandArgs = None) → str 4075
: Returns: : A HTML embeddable URL for a command.
sublime.get_clipboard_async(callback: Callable[[str], None], size_limit: int = 16777216) 4075
: Get the contents of the clipboard in a callback.
For performance reasons if the size of the clipboard content is bigger than
`size_limit`, an empty string will be passed to the callback.
sublime.get_clipboard(size_limit: int = 16777216) → str : Get the contents of the clipboard.
For performance reasons if the size of the clipboard content is bigger than
`size_limit`, an empty string will be returned.
Deprecated:
: Use [`get_clipboard_async`](#sublime.get_clipboard_async) instead.
4075
sublime.set_clipboard(text: str) : Set the contents of the clipboard.
sublime.log_commands(flag: bool | None = None) : Control whether commands are logged to the console when run.
Parameters:
: `flag`
: Whether to log. Passing None toggles logging. 4099
sublime.get_log_commands() → bool 4099
: Get whether command logging is enabled.
sublime.log_input(flag: bool | None = None) : Control whether all key presses will be logged to the console. Use this to find the names of certain keys on the keyboard.
Parameters:
: `flag`
: Whether to log. Passing None toggles logging. 4099
sublime.get_log_input() → bool 4099
: Get whether input logging is enabled.
sublime.log_fps(flag: bool | None = None) 4099
: Control whether rendering timings like frames per second get logged.
Parameters:
: `flag`
: Whether to log. Pass `None` to toggle logging.
sublime.get_log_fps() → bool 4099
: Get whether fps logging is enabled.
sublime.log_result_regex(flag: bool | None = None)
: Control whether result regex logging is enabled. Use this to debug
“file_regex” and “line_regex” in build systems.
Parameters:
: `flag`
: Whether to log. Passing None toggles logging. 4099
sublime.get_log_result_regex() → bool 4099
: Get whether result regex logging is enabled.
sublime.log_indexing(flag: bool | None = None) : Control whether indexing logs are printed to the console.
Parameters:
: `flag`
: Whether to log. Passing None toggles logging. 4099
sublime.get_log_indexing() → bool 4099
: Get whether indexing logging is enabled.
sublime.log_build_systems(flag: bool | None = None) : Control whether build system logs are printed to the console.
Parameters:
: `flag`
: Whether to log. Passing None toggles logging. 4099
sublime.get_log_build_systems() → bool 4099
: Get whether build system logging is enabled.
sublime.log_control_tree(flag: bool | None = None) 4064
: Control whether control tree logging is enabled. When enabled clicking with ctrl+alt will log the control tree under the mouse to the console.
Parameters:
: `flag`
: Whether to log. Passing None toggles logging. 4099
sublime.get_log_control_tree() → bool 4099
: Get whether control tree logging is enabled.
sublime.ui_info() → dict[str, Value] 4096
: Returns:
: Information about the user interface including top-level keys
system, theme and color_scheme.
sublime.score_selector(scope_name: str, selector: str) → int
: Match the selector against the given scope_name, returning a score for how well they match.
A score of `0` means no match, above `0` means a match. Different
selectors may be compared against the same scope: a higher score means the
selector is a better match for the scope.
sublime.load_resource(name: str, max_size=16777216) → str : Loads the given resource. The name should be in the format “Packages/Default/Main.sublime-menu”.
Resources are loaded synchronously. Loading large resources can cause the
application to stutter or not respond.
Parameters:
: `max_size`
4201
: The maximum size of the resource to load.
Raises [`FileNotFoundError`](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError):
: if resource is not found.
Raises [`FileTooLargeError`](#sublime.FileTooLargeError):
: if resource exceeds `max_size`.
Raises [`IsADirectoryError`](https://docs.python.org/3/builtins/exceptions.html#IsADirectoryError):
: if resource is not a file, but a directory.
sublime.load_binary_resource(name: str, max_size=16777216) → bytes : Loads the given resource. The name should be in the format “Packages/Default/Main.sublime-menu”.
Resources are loaded synchronously. Loading large resources can cause the
application to stutter or not respond.
Parameters:
: `max_size`
4201
: The maximum size of the resource to load.
Raises [`FileNotFoundError`](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError):
: if resource is not found.
Raises [`FileTooLargeError`](#sublime.FileTooLargeError):
: if resource exceeds `max_size`.
Raises [`IsADirectoryError`](https://docs.python.org/3/builtins/exceptions.html#IsADirectoryError):
: if resource is not a file, but a directory.
sublime.find_resources(pattern: str) → list[str] : Finds resources whose file name matches the given glob pattern.
sublime.encode_value(value: Value, pretty=False, update_text: str | None = None) → str
: Encode a JSON compatible Value into a string representation.
Parameters:
: `pretty`
: Whether the result should include newlines and be indented.
`update_text`
4156
: Incrementally update the value encoded in this text. Best effort is made
to preserve the contents of `update_text` - comments, indentation,
etc. This is the same algorithm used to change settings values.
Providing this makes `pretty` have no effect.
sublime.decode_value(data: str) → Value : Decode a JSON string into an object. Note that comments and trailing commas are allowed.
Raises [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError):
: If the string is not valid JSON.
sublime.expand_variables(value: Value, variables: dict[str, str]) → Value
: Expands any variables in value using the variables defined in the
dictionary variables. value may also be a list or dict, in which case the
structure will be recursively expanded. Strings should use snippet syntax,
for example: expand_variables(“Hello, ${name}”, {“name”: “Foo”}).
sublime.load_settings(base_name: str) → Settings : Loads the named settings. The name should include a file name and extension, but not a path. The packages will be searched for files matching the base_name, and the results will be collated into the settings object.
Subsequent calls to load\_settings() with the base\_name will return the same
object, and not load the settings from disk again.
sublime.save_settings(base_name: str) : Flush any in-memory changes to the named settings object to disk.
sublime.set_timeout(callback: Callable[[], None], delay: int = 0)
: Run the callback in the main thread after the given delay
(in milliseconds). Callbacks with an equal delay will be run in the order
they were added.
sublime.set_timeout_async(callback: Callable[[], None], delay: int = 0) : Runs the callback on an alternate thread after the given delay (in milliseconds).
sublime.active_window() → Window
: Returns:
: The most recently used Window.
sublime.windows() → list[Window] : Returns: : A list of all the open windows.
sublime.get_macro() → list[dict[str, __annotationlib_name_1__ | CommandArgs]]
: Returns:
: A list of the commands and args that compromise the currently
recorded macro. Each dict will contain the keys “command”
and “args”.
sublime.project_history() → list[str] 4144
: Returns: : A list of most recently opened workspaces. Sublime-project files with the same name are listed in place of sublime-workspace files.
sublime.folder_history() → list[str] 4144
: Returns: : A list of recent folders added to sublime projects
class sublime.Window
: Bases: object
id() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: A number that uniquely identifies this window.
is\_valid() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Check whether this window is still valid. Will return `False` for a
closed window, for example.
hwnd() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: A platform specific window handle. Windows only.
active\_sheet() → [Sheet](#sublime.Sheet) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The currently focused [`Sheet`](#sublime.Sheet).
active\_view() → [View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The currently edited [`View`](#sublime.View).
new\_html\_sheet(*name: [str](#sublime.TextChange.str)*, *contents: [str](#sublime.TextChange.str)*, *flags=NewFileFlags.NONE*, *group=-1*) → [Sheet](#sublime.Sheet)
4065
: Construct a sheet with HTML contents rendered using [minihtml Reference](https://www.sublimetext.com/docs/minihtml.html).
Parameters:
: `name`
: The name of the sheet to show in the tab.
`contents`
: The HTML contents of the sheet.
`flags`
: Only [`NewFileFlags.TRANSIENT`](#sublime.NewFileFlags.TRANSIENT) and
[`NewFileFlags.ADD_TO_SELECTION`](#sublime.NewFileFlags.ADD_TO_SELECTION) are allowed.
`group`
: The group to add the sheet to. `-1` for the active group.
run\_command(*cmd: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs) = None*)
: Run the named [`WindowCommand`](#sublime_plugin.WindowCommand) with the (optional) given args. This
method is able to run any sort of command, dispatching the command via
input focus.
new\_file(*flags=NewFileFlags.NONE*, *syntax=''*) → [View](#sublime.View)
: Create a new empty file.
Parameters:
: `flags`
: Either `0`, [`NewFileFlags.TRANSIENT`](#sublime.NewFileFlags.TRANSIENT) or [`NewFileFlags.ADD_TO_SELECTION`](#sublime.NewFileFlags.ADD_TO_SELECTION).
`syntax`
: The name of the syntax to apply to the file.
Returns:
: The view for the file.
open\_file(*fname: [str](#sublime.TextChange.str)*, *flags=NewFileFlags.NONE*, *group=-1*) → [View](#sublime.View)
: Open the named file. If the file is already opened, it will be brought
to the front. Note that as file loading is asynchronous, operations on
the returned view won’t be possible until its `is_loading()` method
returns `False`.
Parameters:
: `fname`
: The path to the file to open.
`flags`
: [`NewFileFlags`](#sublime.NewFileFlags)
`group`
: The group to add the sheet to. `-1` for the active group.
find\_open\_file(*fname: [str](#sublime.TextChange.str)*, *group=-1*) → [View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Find a opened file by file name.
Parameters:
: `fname`
: The path to the file to open.
`group`
: The group in which to search for the file. `-1` for any group.
Returns:
: The [`View`](#sublime.View) to the file or `None` if the file isn’t open.
file\_history() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)]
: Get the list of previously opened files. This is the same list
as *File > Open Recent*.
num\_groups() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: The number of view groups in the window.
active\_group() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: The index of the currently selected group.
focus\_group(*idx: [int](https://docs.python.org/3/builtins/functions.html#int)*)
: Focus the specified group, making it active.
focus\_sheet(*sheet: [Sheet](#sublime.Sheet)*)
: Switches to the given [`Sheet`](#sublime.Sheet).
focus\_view(*view: [View](#sublime.View)*)
: Switches to the given [`View`](#sublime.View).
select\_sheets(*sheets: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Sheet](#sublime.Sheet)]*)
4083
: Change the selected sheets for the entire window.
bring\_to\_front()
: Bring the window in front of any other windows.
get\_sheet\_index(*sheet: [Sheet](#sublime.Sheet)*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]
: Returns:
: The a tuple of the group and index within the group of the
given [`Sheet`](#sublime.Sheet).
get\_view\_index(*view: [View](#sublime.View)*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]
: Returns:
: The a tuple of the group and index within the group of the
given [`View`](#sublime.View).
set\_sheet\_index(*sheet: [Sheet](#sublime.Sheet)*, *group: [int](https://docs.python.org/3/builtins/functions.html#int)*, *index: [int](https://docs.python.org/3/builtins/functions.html#int)*)
: Move the given [`Sheet`](#sublime.Sheet) to the given `group` at the given `index`.
set\_view\_index(*view: [View](#sublime.View)*, *group: [int](https://docs.python.org/3/builtins/functions.html#int)*, *index: [int](https://docs.python.org/3/builtins/functions.html#int)*)
: Move the given [`View`](#sublime.View) to the given `group` at the given `index`.
move\_sheets\_to\_group(*sheets: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Sheet](#sublime.Sheet)]*, *group: [int](https://docs.python.org/3/builtins/functions.html#int)*, *insertion\_idx=-1*, *select=True*)
4123
: Moves all provided sheets to specified group at insertion index
provided. If an index is not provided defaults to last index of the
destination group.
Parameters:
: `sheets`
: The sheets to move.
`group`
: The index of the group to move the sheets to.
`insertion_idx`
: The point inside the group at which to insert the sheets.
`select`
: Whether the sheets should be selected after moving them.
sheets() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Sheet](#sublime.Sheet)]
: Returns:
: All open sheets in the window.
views(*\**, *include\_transient=False*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[View](#sublime.View)]
: Parameters:
: `include_transient`
4081
: Whether the transient sheet should be included.
Returns:
: All open sheets in the window.
selected\_sheets() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Sheet](#sublime.Sheet)]
4083
: Returns:
: All selected sheets in the window’s currently selected group.
selected\_sheets\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Sheet](#sublime.Sheet)]
4083
: Returns:
: All selected sheets in the specified group.
active\_sheet\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [Sheet](#sublime.Sheet) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The currently focused [`Sheet`](#sublime.Sheet) in the given group.
active\_view\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The currently focused [`View`](#sublime.View) in the given group.
sheets\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Sheet](#sublime.Sheet)]
: Returns:
: A list of all sheets in the specified group.
views\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[View](#sublime.View)]
: Returns:
: A list of all views in the specified group.
num\_sheets\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: The number of sheets in the specified group.
num\_views\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: The number of views in the specified group.
transient\_sheet\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [Sheet](#sublime.Sheet) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The transient sheet in the specified group.
transient\_view\_in\_group(*group: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The transient view in the specified group.
promote\_sheet(*sheet: [Sheet](#sublime.Sheet)*)
: Promote the ‘Sheet’ parameter if semi-transient or transient.
Since:
: 4135
layout() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]
: Get the group layout of the window.
get\_layout() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]
: Deprecated:
: Use [`layout()`](#sublime.Window.layout) instead
set\_layout(*layout: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]*)
: Set the group layout of the window.
create\_output\_panel(*name: [str](#sublime.TextChange.str)*, *unlisted=False*) → [View](#sublime.View)
: Find the [`View`](#sublime.View) associated with the named output panel, creating it if
required. The output panel can be shown by running the `show_panel`
window command, with the `panel` argument set to the name with
an `“output.”` prefix.
Parameters:
: `name`
: The name of the output panel.
`unlisted`
: Control if the output panel should be listed in the panel switcher.
find\_output\_panel(*name: [str](#sublime.TextChange.str)*) → [View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The [`View`](#sublime.View) associated with the named output panel, or `None` if
the output panel does not exist.
destroy\_output\_panel(*name: [str](#sublime.TextChange.str)*)
: Destroy the named output panel, hiding it if currently open.
create\_io\_panel(*name: [str](#sublime.TextChange.str)*, *on\_input: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[str](#sublime.TextChange.str)], [None](https://docs.python.org/3/builtins/constants.html#None)]*, *unlisted=False*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[View](#sublime.View), [View](#sublime.View)]
: Just like [`create_output_panel`](#sublime.Window.create_output_panel), find the view(s) associated with the
named output panel, creating it if required. The output panel will
additionally be configured with an input box. The panel can be shown by
running the `show_panel` window command, with the `panel` argument
set to the name with an `“output.”` prefix.
Parameters:
: `name`
: The name of the output panel.
`on_input`
: Called with any text submitted from the input box.
`unlisted`
: Control if the output panel should be listed in the panel switcher.
Returns:
: A `tuple` containing the [`View`](#sublime.View) for the output and another [`View`](#sublime.View)
for the input.
find\_io\_panel(*name: [str](#sublime.TextChange.str)*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None), [View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None)]
: Returns:
: The output [`View`](#sublime.View) associated with the named output panel and if the
output panel has an input box it also returns its [`View`](#sublime.View); or ``
(None, None)`` if the output panel does not exist.
active\_panel() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns the name of the currently open panel, or None if no panel is
open. Will return built-in panel names (e.g. `“console”`, `“find”`,
etc) in addition to output panels.
panels() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)]
: Returns a list of the names of all panels that have not been marked as
unlisted. Includes certain built-in panels in addition to output
panels.
get\_output\_panel(*name: [str](#sublime.TextChange.str)*) → [View](#sublime.View)
: Deprecated:
: Use [`create_output_panel`](#sublime.Window.create_output_panel) instead.
show\_input\_panel(*caption: [str](#sublime.TextChange.str)*, *initial\_text: [str](#sublime.TextChange.str)*, *on\_done: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[str](#sublime.TextChange.str)], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None)*, *on\_change: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[str](#sublime.TextChange.str)], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None)*, *on\_cancel: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None)*)
: Shows the input panel, to collect a line of input from the user.
Parameters:
: `caption`
: The label to put next to the input widget.
`initial_text`
: The initial text inside the input widget.
`on_done`
: Called with the final input when the user presses `enter`.
`on_change`
: Called with the input when it’s changed.
`on_cancel`
: Called when the user cancels input using `esc`
Returns:
: The [`View`](#sublime.View) used for the input widget.
show\_quick\_panel(*items: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)] | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)]] | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[QuickPanelItem](#sublime.QuickPanelItem)]*, *on\_select: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[int](https://docs.python.org/3/builtins/functions.html#int)], [None](https://docs.python.org/3/builtins/constants.html#None)]*, *flags=QuickPanelFlags.NONE*, *selected\_index=-1*, *on\_highlight: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[int](https://docs.python.org/3/builtins/functions.html#int)], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *placeholder: [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*)
: Show a quick panel to select an item in a list. on\_select will be called
once, with the index of the selected item. If the quick panel was
cancelled, on\_select will be called with an argument of -1.
Parameters:
: `items`
: May be either a list of strings, or a list of lists of strings where
the first item is the trigger and all subsequent strings are
details shown below.
May be a [`QuickPanelItem`](#sublime.QuickPanelItem).
4083
`on_select`
: Called with the selected item’s index when the quick panel is
completed. If the panel was cancelled this is called with `-1`.
A second [`Event`](#sublime.Event) argument may be passed when the
[`QuickPanelFlags.WANT_EVENT`](#sublime.QuickPanelFlags.WANT_EVENT) flag is present.
4096
`flags`
: [`QuickPanelFlags`](#sublime.QuickPanelFlags) controlling behavior.
`selected_index`
: The initially selected item. `-1` for no selection.
`on_highlight`
: Called every time the highlighted item in the quick panel is changed.
`placeholder`
4081
: Text displayed in the filter input field before any query is typed.
is\_sidebar\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the sidebar is visible.
set\_sidebar\_visible(*flag: [bool](https://docs.python.org/3/builtins/functions.html#bool)*, *animate=True*)
: Hides or shows the sidebar.
is\_minimap\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the minimap is visible.
set\_minimap\_visible(*flag: [bool](https://docs.python.org/3/builtins/functions.html#bool)*)
: Hides or shows the minimap.
is\_status\_bar\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the status bar is visible.
set\_status\_bar\_visible(*flag: [bool](https://docs.python.org/3/builtins/functions.html#bool)*)
: Hides or shows the status bar.
get\_tabs\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the tabs are visible.
set\_tabs\_visible(*flag: [bool](https://docs.python.org/3/builtins/functions.html#bool)*)
: Hides or shows the tabs.
is\_menu\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the menu is visible.
set\_menu\_visible(*flag: [bool](https://docs.python.org/3/builtins/functions.html#bool)*)
: Hides or shows the menu.
folders() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)]
: Returns:
: A list of the currently open folders in this [`Window`](#sublime.Window).
project\_file\_name() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The name of the currently opened project file, if any.
workspace\_file\_name() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
4050
: Returns:
: The name of the currently opened workspace file, if any.
project\_data() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [Value](#sublime.Value)] | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The project data associated with the current window. The data
is in the same format as the contents of a
.sublime-project file.
set\_project\_data(*data: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]*)
: Updates the project data associated with the current window. If the
window is associated with a .sublime-project file, the project
file will be updated on disk, otherwise the window will store the data
internally.
settings() → [Settings](#sublime.Settings)
: Returns:
: The [`Settings`](#sublime.Settings) object for this [`Window`](#sublime.Window). Any changes to this
settings object will be specific to this window.
template\_settings() → [Settings](#sublime.Settings)
: Returns:
: Per-window settings that are persisted in the session, and
duplicated into new windows.
symbol\_locations(*sym: [str](#sublime.TextChange.str)*, *source=SymbolSource.ANY*, *type=SymbolType.ANY*, *kind\_id=KindId.AMBIGUOUS*, *kind\_letter=''*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[SymbolLocation](#sublime.SymbolLocation)]
4085
: Find all locations where the symbol `sym` is located.
Parameters:
: `sym`
: The name of the symbol.
`source`
: Sources which should be searched for the symbol.
`type`
: The type of symbol to find
`kind_id`
: The [`KindId`](#sublime.KindId) of the symbol.
`kind_letter`
: The letter representing the kind of the symbol. See [`Kind`](#sublime.Kind).
Return:
: the found symbol locations.
lookup\_symbol\_in\_index(*symbol: [str](#sublime.TextChange.str)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[SymbolLocation](#sublime.SymbolLocation)]
: Returns:
: All locations where the symbol is defined across files in the current project.
Deprecated:
: Use [`symbol_locations()`](#sublime.Window.symbol_locations) instead.
lookup\_symbol\_in\_open\_files(*symbol: [str](#sublime.TextChange.str)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[SymbolLocation](#sublime.SymbolLocation)]
: Returns:
: All locations where the symbol is defined across open files.
Deprecated:
: Use [`symbol_locations()`](#sublime.Window.symbol_locations) instead.
lookup\_references\_in\_index(*symbol: [str](#sublime.TextChange.str)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[SymbolLocation](#sublime.SymbolLocation)]
: Returns:
: All locations where the symbol is referenced across files in the current project.
Deprecated:
: Use [`symbol_locations()`](#sublime.Window.symbol_locations) instead.
lookup\_references\_in\_open\_files(*symbol: [str](#sublime.TextChange.str)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[SymbolLocation](#sublime.SymbolLocation)]
: Returns:
: All locations where the symbol is referenced across open files.
Deprecated:
: Use [`symbol_locations()`](#sublime.Window.symbol_locations) instead.
extract\_variables() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [str](#sublime.TextChange.str)]
: Get the `dict` of contextual keys of the window.
May contain:
\* `“packages”`
\* `“platform”`
\* `“file”`
\* `“file_path”`
\* `“file_name”`
\* `“file_base_name”`
\* `“file_extension”`
\* `“folder”`
\* `“project”`
\* `“project_path”`
\* `“project_name”`
\* `“project_base_name”`
\* `“project_extension”`
This `dict` is suitable for use with [`expand_variables()`](#sublime.expand_variables).
status\_message(*msg: [str](#sublime.TextChange.str)*)
: Show a message in the status bar.
class sublime.Edit
: Bases: object
A grouping of buffer modifications.
Edit objects are passed to [`TextCommand`](#sublime_plugin.TextCommand)s, and can not be created by the
user. Using an invalid Edit object, or an Edit object from a different
[`View`](#sublime.View), will cause the functions that require them to fail.
class sublime.Region
: Bases: object
A singular selection region. This region has a order - `b` may be before
or at `a`.
Also commonly used to represent an area of the text buffer, where ordering
and `xpos` are generally ignored.
a: [Point](#sublime.Point)
: The first end of the region.
b: [Point](#sublime.Point)
: The second end of the region. In a selection this is the location of the
caret. May be less than `a`.
xpos: [DIP](#sublime.DIP)
: In a selection this is the target horizontal position of the region.
This affects behavior when pressing the up or down keys. Use `-1` if
undefined.
\_\_len\_\_() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: The size of the region.
\_\_contains\_\_(*v: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4023 3.8
: Returns:
: Whether the provided [`Region`](#sublime.Region) or [`Point`](#sublime.Point) is entirely contained
within this region.
to\_tuple() → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Point](#sublime.Point), [Point](#sublime.Point)]
4075
: Returns:
: This region as a tuple `(a, b)`.
empty() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the region is empty, ie. `a == b`.
begin() → [Point](#sublime.Point)
: Returns:
: The smaller of `a` and `b`.
end() → [Point](#sublime.Point)
: Returns:
: The larger of `a` and `b`.
size() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Equivalent to [`__len__`](#sublime.Region.__len__).
contains(*x: [Point](#sublime.Point)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Equivalent to [`__contains__`](#sublime.Region.__contains__).
cover(*region: [Region](#sublime.Region)*) → [Region](#sublime.Region)
: Returns:
: A [`Region`](#sublime.Region) spanning both regions.
intersection(*region: [Region](#sublime.Region)*) → [Region](#sublime.Region)
: Returns:
: A [`Region`](#sublime.Region) covered by both regions.
intersects(*region: [Region](#sublime.Region)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the provided region intersects this region.
class sublime.HistoricPosition 4050
: Bases: object
Provides a snapshot of the row and column info for a [`Point`](#sublime.Point), before changes
were made to a [`View`](#sublime.View). This is primarily useful for replaying changes to a
document.
pt: [Point](#sublime.Point)
: The offset from the beginning of the [`View`](#sublime.View).
row: [int](https://docs.python.org/3/builtins/functions.html#int)
: The row the `.py` was in when the [`HistoricPosition`](#sublime.HistoricPosition) was recorded.
col: [int](https://docs.python.org/3/builtins/functions.html#int)
: The column the `.py` was in when the [`HistoricPosition`](#sublime.HistoricPosition) was recorded, in Unicode characters.
col\_utf16: [int](https://docs.python.org/3/builtins/functions.html#int)
4075
: The value of `.col`, but in UTF-16 code units.
col\_utf8: [int](https://docs.python.org/3/builtins/functions.html#int)
4075
: The value of `.col`, but in UTF-8 code units.
class sublime.TextChange 4050
: Bases: object
Represents a change that occurred to the text of a [`View`](#sublime.View). This is primarily
useful for replaying changes to a document.
a: [HistoricPosition](#sublime.HistoricPosition)
: The beginning [`HistoricPosition`](#sublime.HistoricPosition) of the region that was modified.
b: [HistoricPosition](#sublime.HistoricPosition)
: The ending [`HistoricPosition`](#sublime.HistoricPosition) of the region that was modified.
len\_utf16: [int](https://docs.python.org/3/builtins/functions.html#int)
4075
: The length of the old contents, in UTF-16 code units.
len\_utf8: [int](https://docs.python.org/3/builtins/functions.html#int)
4075
: The length of the old contents, in UTF-8 code units.
str: [str](#sublime.TextChange.str)
: A string of the *new* contents of the region specified by `.a` and `.b`.
class sublime.Selection
: Bases: object
Maintains a set of sorted non-overlapping Regions. A selection may be
empty.
This is primarily used to represent the textual selection.
\_\_len\_\_() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: The number of regions in the selection.
\_\_getitem\_\_(*index: [int](https://docs.python.org/3/builtins/functions.html#int)*) → [Region](#sublime.Region)
: Returns:
: The region at the given `index`.
\_\_delitem\_\_(*index: [int](https://docs.python.org/3/builtins/functions.html#int)*)
: Delete the region at the given `index`.
is\_valid() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether this selection is for a valid view.
clear()
: Remove all regions from the selection.
add(*x: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*)
: Add a [`Region`](#sublime.Region) or [`Point`](#sublime.Point) to the selection. It will be merged with the
existing regions if intersecting.
add\_all(*regions: [Iterable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable)[\_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)]*)
: Add all the regions from the given iterable.
subtract(*region: [Region](#sublime.Region)*)
: Subtract a region from the selection, such that the whole region is no
longer contained within the selection.
contains(*region: [Region](#sublime.Region)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the provided region is contained within the selection.
has\_empty\_region() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4193
: Returns:
: Whether the selection has an empty region
has\_non\_empty\_region() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4193
: Returns:
: Whether the selection has an non-empty region
has\_multiple\_non\_empty\_regions() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4193
: Returns:
: Whether the selection has more than one non-empty region
class sublime.Sheet
: Bases: object
Represents a content container, i.e. a tab, within a window. Sheets may
contain a View, or an image preview.
id() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: A number that uniquely identifies this sheet.
window() → [Window](#sublime.Window) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The [`Window`](#sublime.Window) containing this sheet. May be `None` if the
sheet has been closed.
view() → [View](#sublime.View) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The [`View`](#sublime.View) contained within the sheet if any.
name() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The name assigned to the sheet, if any.
set\_name(*name: [str](#sublime.TextChange.str)*)
: Set the name displayed in the tab. Doesn’t affect saved TextSheets.
file\_name() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
4088
: Returns:
: The full name of the file associated with the sheet, or `None`
if it doesn’t exist on disk.
is\_semi\_transient() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4080
: Returns:
: Whether this sheet is semi-transient.
is\_transient() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4080
: Returns:
: Whether this sheet is exclusively transient.
Note that a sheet may be both open as a regular file and be
transient. In this case [`is_transient`](#sublime.Sheet.is_transient) will still return `False`.
is\_selected() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether this sheet is currently selected.
Since:
: 4135
group() → [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None)
4100
: Returns:
: The (layout) group that the sheet is contained within.
close(*on\_close=<function Sheet.<lambda>>*)
4088
: Closes the sheet.
Parameters:
: `on_close`
class sublime.TextSheet 4065
: Bases: Sheet
Specialization for sheets containing editable text, ie. a [`View`](#sublime.View).
class sublime.ImageSheet 4065
: Bases: Sheet
Specialization for sheets containing an image.
class sublime.HtmlSheet 4065
: Bases: Sheet
Specialization for sheets containing HTML.
set\_contents(*contents: [str](#sublime.TextChange.str)*)
: Set the HTML content of the sheet.
class sublime.ContextStackFrame 4127
: Bases: object
Represents a single stack frame in the syntax highlighting. See
[`View.context_backtrace`](#sublime.View.context_backtrace).
context\_name: [str](#sublime.TextChange.str)
: The name of the context.
source\_file: [str](#sublime.TextChange.str)
: The name of the file the context is defined in.
source\_location: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]
: The location of the context inside the source file as a pair of row and
column. Maybe be `(-1, -1)` if the location is unclear, like in
`tmLanguage` based syntaxes.
class sublime.View
: Bases: object
Represents a view into a text [`Buffer`](#sublime.Buffer).
Note that multiple views may refer to the same [`Buffer`](#sublime.Buffer), but they have their
own unique selection and geometry. A list of these may be gotten using
[`View.clones()`](#sublime.View.clones) or [`Buffer.views()`](#sublime.Buffer.views).
id() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: A number that uniquely identifies this view.
buffer\_id() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: A number that uniquely identifies this view’s [`Buffer`](#sublime.Buffer).
buffer() → [Buffer](#sublime.Buffer)
: Returns:
: The [`Buffer`](#sublime.Buffer) for which this is a view.
sheet\_id() → [int](https://docs.python.org/3/builtins/functions.html#int)
4083
: Returns:
: The ID of the [`Sheet`](#sublime.Sheet) for this [`View`](#sublime.View), or `0` if not part of any
sheet.
sheet() → [Sheet](#sublime.Sheet) | [None](https://docs.python.org/3/builtins/constants.html#None)
4083
: Returns:
: The [`Sheet`](#sublime.Sheet) for this view, if displayed in a sheet.
element() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
4050
: Returns:
: `None` for normal views that are part of a [`Sheet`](#sublime.Sheet). For views that
comprise part of the UI a string is returned from the following
list:
- `“console:input”` - The console input.
- `“goto_anything:input”` - The input for the Goto Anything.
- `“command_palette:input”` - The input for the Command Palette.
- `“find:input”` - The input for the Find panel.
- `“incremental_find:input”` - The input for the Incremental Find panel.
- `“replace:input:find”` - The Find input for the Replace panel.
- `“replace:input:replace”` - The Replace input for the Replace panel.
- `“find_in_files:input:find”` - The Find input for the Find in Files panel.
- `“find_in_files:input:location”` - The Where input for the Find in Files panel.
- `“find_in_files:input:replace”` - The Replace input for the Find in Files panel.
- `“find_in_files:output”` - The output panel for Find in Files (buffer or output panel).
- `“input:input”` - The input for the Input panel.
- `“exec:output”` - The output for the exec command.
- `“output:output”` - A general output panel.
The console output, indexer status output and license input controls
are not accessible via the API.
is\_valid() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Check whether this view is still valid. Will return `False` for a
closed view, for example.
is\_primary() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether view is the primary view into a [`Buffer`](#sublime.Buffer). Will only be
`False` if the user has opened multiple views into a file.
window() → [Window](#sublime.Window) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: A reference to the window containing the view, if any.
clones() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[View](#sublime.View)]
: Returns:
: All the other views into the same [`Buffer`](#sublime.Buffer). See [`View`](#sublime.View).
file\_name() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The full name of the file associated with the sheet, or
`None` if it doesn’t exist on disk.
close(*on\_close=<function View.<lambda>>*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Closes the view.
retarget(*new\_fname: [str](#sublime.TextChange.str)*)
: Change the file path the buffer will save to.
name() → [str](#sublime.TextChange.str)
: Returns:
: The name assigned to the buffer, if any.
set\_name(*name: [str](#sublime.TextChange.str)*)
: Assign a name to the buffer. Displayed as in the tab.
reset\_reference\_document()
: Clears the state of the [incremental diff](https://www.sublimetext.com/docs/incremental_diff.html) for the
view.
set\_reference\_document(*reference: [str](#sublime.TextChange.str)*)
: Uses the string reference to calculate the initial diff for the
[incremental diff](https://www.sublimetext.com/docs/incremental_diff.html).
is\_loading() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the buffer is still loading from disk, and not ready
for use.
is\_dirty() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether there are any unsaved modifications to the buffer.
is\_read\_only() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the buffer may not be modified.
set\_read\_only(*read\_only: [bool](https://docs.python.org/3/builtins/functions.html#bool)*)
: Set the read only property on the buffer.
is\_scratch() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the buffer is a scratch buffer. See [`set_scratch()`](#sublime.View.set_scratch).
set\_scratch(*scratch: [bool](https://docs.python.org/3/builtins/functions.html#bool)*)
: Sets the scratch property on the buffer. When a modified scratch buffer
is closed, it will be closed without prompting to save. Scratch buffers
never report as being dirty.
encoding() → [str](#sublime.TextChange.str)
: Returns:
: The encoding currently associated with the buffer.
set\_encoding(*encoding\_name: [str](#sublime.TextChange.str)*)
: Applies a new encoding to the file. This will be used when the file is
saved.
line\_endings() → [str](#sublime.TextChange.str)
: Returns:
: The encoding currently associated with the file.
set\_line\_endings(*line\_ending\_name: [str](#sublime.TextChange.str)*)
: Sets the line endings that will be applied when next saving.
size() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Returns:
: The number of character in the file.
insert(*edit: [Edit](#sublime.Edit)*, *pt: [Point](#sublime.Point)*, *text: [str](#sublime.TextChange.str)*) → [int](https://docs.python.org/3/builtins/functions.html#int)
: Insert the given string into the buffer.
Parameters:
: `edit`
: An [`Edit`](#sublime.Edit) object provided by a [`TextCommand`](#sublime_plugin.TextCommand).
`point`
: The text point in the view where to insert.
`text`
: The text to insert.
Returns:
: The actual number of characters inserted. This may differ
from the provided text due to tab translation.
Raises [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError):
: If the [`Edit`](#sublime.Edit) object is in an invalid state, ie. outside of a [`TextCommand`](#sublime_plugin.TextCommand).
erase(*edit: [Edit](#sublime.Edit)*, *region: [Region](#sublime.Region)*)
: Erases the contents of the provided [`Region`](#sublime.Region) from the buffer.
replace(*edit: [Edit](#sublime.Edit)*, *region: [Region](#sublime.Region)*, *text: [str](#sublime.TextChange.str)*)
: Replaces the contents of the [`Region`](#sublime.Region) in the buffer with the provided string.
change\_count() → [int](https://docs.python.org/3/builtins/functions.html#int)
: Each time the buffer is modified, the change count is incremented. The
change count can be used to determine if the buffer has changed since
the last it was inspected.
Returns:
: The current change count.
change\_id() → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]
: Get a 3-element tuple that can be passed to [`transform_region_from()`](#sublime.View.transform_region_from) to
obtain a region equivalent to a region of the view in the past. This is
primarily useful for plugins providing text modification that must
operate in an asynchronous fashion and must be able to handle the view
contents changing between the request and response.
transform\_region\_from(*region: [Region](#sublime.Region)*, *change\_id: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]*) → [Region](#sublime.Region)
: Transforms a region from a previous point in time to an equivalent
region in the current state of the View. The `change_id` must have
been obtained from [`change_id()`](#sublime.View.change_id) at the point in time the region is
from.
run\_command(*cmd: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs) = None*)
: Run the named [`TextCommand`](#sublime_plugin.TextCommand) with the (optional) given `args`.
sel() → [Selection](#sublime.Selection)
: Returns:
: The views [`Selection`](#sublime.Selection).
substr(*x: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*) → [str](#sublime.TextChange.str)
: Returns:
: The string at the [`Point`](#sublime.Point) or within the [`Region`](#sublime.Region) provided.
find(*pattern: [str](#sublime.TextChange.str)*, *start\_pt: [Point](#sublime.Point)*, *flags=FindFlags.NONE*) → [Region](#sublime.Region)
: Parameters:
: `pattern`
: The regex or literal pattern to search by.
`start_pt`
: The [`Point`](#sublime.Point) to start searching from.
`flags`
: Controls various behaviors of find. See [`FindFlags`](#sublime.FindFlags).
Returns:
: The first [`Region`](#sublime.Region) matching the provided pattern.
find\_all(*pattern: [str](#sublime.TextChange.str)*, *flags=FindFlags.NONE*, *fmt: [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *extractions: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *within: [Region](#sublime.Region) | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]
: Parameters:
: `pattern`
: The regex or literal pattern to search by.
`flags`
: Controls various behaviors of find. See [`FindFlags`](#sublime.FindFlags).
`fmt`
: When not `None` all matches in the `extractions` list
will be formatted with the provided format string.
`extractions`
: An optionally provided list to place the contents of
the find results into.
`within`
4181
: When not `None` searching is limited to within the provided
region(s).
Returns:
: All (non-overlapping) regions matching the pattern.
settings() → [Settings](#sublime.Settings)
: Returns:
: The view’s [`Settings`](#sublime.Settings) object. Any changes to it will be
private to this view.
meta\_info(*key: [str](#sublime.TextChange.str)*, *pt: [Point](#sublime.Point)*) → [Value](#sublime.Value)
: Look up the preference `key` for the scope at the provided [`Point`](#sublime.Point)
from all matching `.tmPreferences` files.
Examples of keys are `TM_COMMENT_START` and `showInSymbolList`.
extract\_tokens\_with\_scopes(*region: [Region](#sublime.Region)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Region](#sublime.Region), [str](#sublime.TextChange.str)]]
: Parameters:
: `region`
: The region from which to extract tokens and scopes.
Returns:
: A list of pairs containing the [`Region`](#sublime.Region) and the scope of each token.
extract\_scope(*pt: [Point](#sublime.Point)*) → [Region](#sublime.Region)
: Returns:
: The extent of the syntax scope name assigned to the character
at the given [`Point`](#sublime.Point), narrower syntax scope names included.
expand\_to\_scope(*pt: [Point](#sublime.Point)*, *selector: [str](#sublime.TextChange.str)*) → [Region](#sublime.Region) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Expand by the provided scope selector from the [`Point`](#sublime.Point).
Parameters:
: `pt`
: The point from which to expand.
`selector`
: The scope selector to match.
Returns:
: The matched [`Region`](#sublime.Region), if any.
scope\_name(*pt: [Point](#sublime.Point)*) → [str](#sublime.TextChange.str)
: Returns:
: The syntax scope name assigned to the character at the given point.
context\_backtrace(*pt: [Point](#sublime.Point)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[ContextStackFrame](#sublime.ContextStackFrame)]
4127
: Get a backtrace of [`ContextStackFrame`](#sublime.ContextStackFrame)s at the provided [`Point`](#sublime.Point).
Note this function is particularly slow.
match\_selector(*pt: [Point](#sublime.Point)*, *selector: [str](#sublime.TextChange.str)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the provided scope selector matches the [`Point`](#sublime.Point).
score\_selector(*pt: [Point](#sublime.Point)*, *selector: [str](#sublime.TextChange.str)*) → [int](https://docs.python.org/3/builtins/functions.html#int)
: Equivalent to:
```
sublime.score_selector(view.scope_name(pt), selector)
```
See [`sublime.score_selector`](#sublime.score_selector).
find\_by\_selector(*selector: [str](#sublime.TextChange.str)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]
: Find all regions in the file matching the given selector.
Returns:
: The list of matched regions.
style() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [str](#sublime.TextChange.str)]
3150
: See [`style_for_scope`](#sublime.View.style_for_scope).
Returns:
: The global style settings for the view. All colors are normalized
to the six character hex form with a leading hash, e.g.
`#ff0000`.
style\_for\_scope(*scope: [str](#sublime.TextChange.str)*) → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]
: Accepts a string scope name and returns a `dict` of style information
including the keys:
- `“foreground”: str`
- `“selection_foreground”: str` (only if set)
- `“background”: str` (only if set)
- `“bold”: bool`
- `“italic”: bool`
- `“glow”: bool` (only if set)
4063
- `“underline”: bool` (only if set)
4075
- `“stippled_underline”: bool` (only if set)
4075
- `“squiggly_underline”: bool` (only if set)
4075
- `“source_line”: str`
- `“source_column”: int`
- `“source_file”: int`
The foreground and background colors are normalized to the six character
hex form with a leading hash, e.g. `#ff0000`.
lines(*region: [Region](#sublime.Region)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]
: Returns:
: A list of lines (in sorted order) intersecting the provided [`Region`](#sublime.Region).
split\_by\_newlines(*region: [Region](#sublime.Region)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]
: Splits the region up such that each [`Region`](#sublime.Region) returned exists on exactly
one line.
line(*x: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*) → [Region](#sublime.Region)
: Returns:
: The line that contains the [`Point`](#sublime.Point) or an expanded [`Region`](#sublime.Region) to the
beginning/end of lines, excluding the newline character.
full\_line(*x: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*) → [Region](#sublime.Region)
: Returns:
: The line that contains the [`Point`](#sublime.Point) or an expanded [`Region`](#sublime.Region) to the
beginning/end of lines, including the newline character.
word(*x: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*) → [Region](#sublime.Region)
: Returns:
: The word that contains the provided [`Point`](#sublime.Point). If a [`Region`](#sublime.Region) is
provided it’s beginning/end are expanded to word boundaries.
classify(*pt: [Point](#sublime.Point)*) → [PointClassification](#sublime.PointClassification)
: Classify the provided [`Point`](#sublime.Point). See [`PointClassification`](#sublime.PointClassification).
find\_by\_class(*pt: [Point](#sublime.Point)*, *forward: [bool](https://docs.python.org/3/builtins/functions.html#bool)*, *classes: [PointClassification](#sublime.PointClassification)*, *separators=''*, *sub\_word\_separators=''*) → [Point](#sublime.Point)
: Find the next location that matches the provided [`PointClassification`](#sublime.PointClassification).
Parameters:
: `pt`
: The point to start searching from.
`forward`
: Whether to search forward or backwards.
`classes`
: The classification to search for.
`separators`
: The word separators to use when classifying.
`sub_word_separators`
4130
: The sub-word separators to use when classifying.
Returns:
: The found point.
expand\_by\_class(*x: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*, *classes: [PointClassification](#sublime.PointClassification)*, *separators=''*, *sub\_word\_separators=''*) → [Region](#sublime.Region)
: Expand the provided [`Point`](#sublime.Point) or [`Region`](#sublime.Region) to the left and right until each
side lands on a location that matches the provided
[`PointClassification`](#sublime.PointClassification). See [`find_by_class`](#sublime.View.find_by_class).
Parameters:
: `classes`
: The classification to search by.
`separators`
: The word separators to use when classifying.
`sub_word_separators`
4130
: The sub-word separators to use when classifying.
rowcol(*tp: [Point](#sublime.Point)*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]
: Calculates the 0-based line and column numbers of the point. Column
numbers are returned as number of Unicode characters.
rowcol\_utf8(*tp: [Point](#sublime.Point)*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]
4069
: Calculates the 0-based line and column numbers of the point. Column
numbers are returned as UTF-8 code units.
rowcol\_utf16(*tp: [Point](#sublime.Point)*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]
4069
: Calculates the 0-based line and column numbers of the point. Column
numbers are returned as UTF-16 code units.
text\_point(*row: [int](https://docs.python.org/3/builtins/functions.html#int)*, *col: [int](https://docs.python.org/3/builtins/functions.html#int)*, *\**, *clamp\_column=False*) → [Point](#sublime.Point)
: Calculates the character offset of the given, 0-based, `row` and
`col`. `col` is interpreted as the number of Unicode characters to
advance past the beginning of the row.
Parameters:
: `clamp_column`
4075
: Whether `col` should be restricted to valid values for the given
`row`.
text\_point\_utf8(*row: [int](https://docs.python.org/3/builtins/functions.html#int)*, *col: [int](https://docs.python.org/3/builtins/functions.html#int)*, *\**, *clamp\_column=False*) → [Point](#sublime.Point)
: Calculates the character offset of the given, 0-based, `row` and
`col`. `col` is interpreted as the number of UTF-8 code units to
advance past the beginning of the row.
Parameters:
: `clamp_column`
4075
: whether `col` should be restricted to valid values for the given
`row`.
text\_point\_utf16(*row: [int](https://docs.python.org/3/builtins/functions.html#int)*, *col: [int](https://docs.python.org/3/builtins/functions.html#int)*, *\**, *clamp\_column=False*) → [Point](#sublime.Point)
: Calculates the character offset of the given, 0-based, `row` and
`col`. `col` is interpreted as the number of UTF-16 code units to
advance past the beginning of the row.
Parameters:
: `clamp_column`
4075
: whether `col` should be restricted to valid values for the given
`row`.
utf8\_code\_units(*tp: [Point](#sublime.Point) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*) → [int](https://docs.python.org/3/builtins/functions.html#int)
4173
: Calculates the utf8 code unit offset at the given text point.
Parameters:
: `tp`
: The text point up to which code units should be counted. If not
provided the total is returned.
utf16\_code\_units(*tp: [Point](#sublime.Point) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*) → [int](https://docs.python.org/3/builtins/functions.html#int)
4173
: Calculates the utf16 code unit offset at the given text point.
Parameters:
: `tp`
: The text point up to which code units should be counted. If not
provided the total is returned.
visible\_region() → [Region](#sublime.Region)
: Returns:
: The currently visible area of the view.
show(*location: [Region](#sublime.Region) | [Selection](#sublime.Selection) | [Point](#sublime.Point)*, *show\_surrounds=True*, *keep\_to\_left=False*, *animate=True*)
: Scroll the view to show the given location.
Parameters:
: `location`
: The location to scroll the view to. For a [`Selection`](#sublime.Selection) only the first
[`Region`](#sublime.Region) is shown.
`show_surrounds`
: Whether to show the surrounding context around the location.
`keep_to_left`
4075
: Whether the view should be kept to the left, if horizontal scrolling
is possible.
`animate`
4075
: Whether the scrolling should be animated.
show\_at\_center(*location: \_\_annotationlib\_name\_1\_\_ | [Point](#sublime.Point)*, *animate=True*)
: Scroll the view to center on the location.
Parameters:
: `location`
: Which [`Point`](#sublime.Point) or [`Region`](#sublime.Region) to scroll to.
`animate`
4075
: Whether the scrolling should be animated.
viewport\_position() → [Vector](#sublime.Vector)
: Returns:
: The offset of the viewport in layout coordinates.
set\_viewport\_position(*xy: [Vector](#sublime.Vector)*, *animate=True*)
: Scrolls the viewport to the given layout position.
viewport\_extent() → [Vector](#sublime.Vector)
: Returns:
: The width and height of the viewport.
layout\_extent() → [Vector](#sublime.Vector)
: Returns:
: The width and height of the layout.
text\_to\_layout(*tp: [Point](#sublime.Point)*) → [Vector](#sublime.Vector)
: Convert a text point to a layout position.
text\_to\_window(*tp: [Point](#sublime.Point)*) → [Vector](#sublime.Vector)
: Convert a text point to a window position.
layout\_to\_text(*xy: [Vector](#sublime.Vector)*) → [Point](#sublime.Point)
: Convert a layout position to a text point.
layout\_to\_window(*xy: [Vector](#sublime.Vector)*) → [Vector](#sublime.Vector)
: Convert a layout position to a window position.
window\_to\_layout(*xy: [Vector](#sublime.Vector)*) → [Vector](#sublime.Vector)
: Convert a window position to a layout position.
window\_to\_text(*xy: [Vector](#sublime.Vector)*) → [Point](#sublime.Point)
: Convert a window position to a text point.
line\_height() → [DIP](#sublime.DIP)
: Returns:
: The light height used in the layout.
em\_width() → [DIP](#sublime.DIP)
: Returns:
: The typical character width used in the layout.
is\_folded(*region: [Region](#sublime.Region)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the provided [`Region`](#sublime.Region) is folded.
folded\_regions() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]
: Returns:
: The list of folded regions.
fold(*x: [Region](#sublime.Region) | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Fold the provided [`Region`](#sublime.Region) (s).
Returns:
: `False` if the regions were already folded.
unfold(*x: [Region](#sublime.Region) | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]
: Unfold all text in the provided [`Region`](#sublime.Region) (s).
Returns:
: The unfolded regions.
add\_regions(*key: [str](#sublime.TextChange.str)*, *regions: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]*, *scope=''*, *icon=''*, *flags=RegionFlags.NONE*, *annotations: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)] = []*, *annotation\_color=''*, *on\_navigate: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[str](#sublime.TextChange.str)], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *on\_close: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*)
: Adds visual indicators to regions of text in the view. Indicators
include icons in the gutter, underlines under the text, borders around
the text and annotations. Annotations are drawn aligned to the
right-hand edge of the view and may contain HTML markup.
Parameters:
: `key`
: An identifier for the collection of regions. If a set of regions
already exists for this key they will be overridden. See
[`get_regions`](#sublime.View.get_regions).
`regions`
: The list of regions to add. These should not overlap.
`scope`
: An optional string used to source a color to draw the regions in.
The scope is matched against the color scheme. Examples include:
`“invalid”` and `“string”`. See [Scope Naming](https://www.sublimetext.com/docs/scope_naming.html)
for a list of common scopes. If the scope is empty, the regions
won’t be drawn.
Also supports the following pseudo-scopes, to allow picking the
closest color from the user‘s color scheme:
- `“region.redish”`
- `“region.orangish”`
- `“region.yellowish”`
- `“region.greenish”`
- `“region.cyanish”`
- `“region.bluish”`
- `“region.purplish”`
- `“region.pinkish”`
3148
`icon`
: An optional string specifying an icon to draw in the gutter next to
each region. The icon will be tinted using the color associated
with the `scope`. Standard icon names are `“dot”`, ``` “circle”`
and ``“bookmark” ```. The icon may also be a full package-relative
path, such as `“Packages/Theme - Default/dot.png”`.
`flags`
: Flags specifying how the region should be drawn, among other
behavior. See [`RegionFlags`](#sublime.RegionFlags).
`annotations`
4050
: An optional collection of strings containing HTML documents to
display along the right-hand edge of the view. There should be the
same number of annotations as regions. See [minihtml Reference](https://www.sublimetext.com/docs/minihtml.html) for supported
HTML.
`annotation_color`
4050
: An optional string of the CSS color to use when drawing the left
border of the annotation. See [minihtml Reference: Colors](https://www.sublimetext.com/docs/minihtml.html#colors) for supported color formats.
`on_navigate`
4050
: Called when a link in an annotation is clicked. Will be passed the
`href` of the link.
`on_close`
4050
: Called when the annotations are closed.
get\_regions(*key: [str](#sublime.TextChange.str)*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)]
: Returns:
: The regions associated with the given `key`, if any.
erase\_regions(*key: [str](#sublime.TextChange.str)*)
: Remove the regions associated with the given `key`.
assign\_syntax(*syntax: [str](#sublime.TextChange.str) | [Syntax](#sublime.Syntax)*)
: Changes the syntax used by the view. `syntax` may be a packages path
to a syntax file, or a `scope:` specifier string.
`syntax` may be a [`Syntax`](#sublime.Syntax) object.
4080
set\_syntax\_file(*syntax\_file: [str](#sublime.TextChange.str)*)
: Deprecated:
: Use [`assign_syntax()`](#sublime.View.assign_syntax) instead.
syntax() → [Syntax](#sublime.Syntax) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Returns:
: The syntax assigned to the buffer.
symbols() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Region](#sublime.Region), [str](#sublime.TextChange.str)]]
: Extract all the symbols defined in the buffer.
Deprecated:
: Use [`symbol_regions()`](#sublime.View.symbol_regions) instead.
get\_symbols() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Region](#sublime.Region), [str](#sublime.TextChange.str)]]
: Deprecated:
: Use [`symbol_regions()`](#sublime.View.symbol_regions) instead.
indexed\_symbols() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Region](#sublime.Region), [str](#sublime.TextChange.str)]]
3148
: Returns:
: A list of the [`Region`](#sublime.Region) and name of symbols.
Deprecated:
: Use [`indexed_symbol_regions()`](#sublime.View.indexed_symbol_regions) instead.
indexed\_references() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Region](#sublime.Region), [str](#sublime.TextChange.str)]]
3148
: Returns:
: A list of the [`Region`](#sublime.Region) and name of symbols.
Deprecated:
: Use [`indexed_symbol_regions()`](#sublime.View.indexed_symbol_regions) instead.
symbol\_regions() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[SymbolRegion](#sublime.SymbolRegion)]
4085
: Returns:
: Info about symbols that are part of the view’s symbol list.
indexed\_symbol\_regions(*type=SymbolType.ANY*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[SymbolRegion](#sublime.SymbolRegion)]
4085
: Parameters:
: `type`
: The type of symbol to return.
Returns:
: Info about symbols that are indexed.
set\_status(*key: [str](#sublime.TextChange.str)*, *value: [str](#sublime.TextChange.str)*)
: Add the status `key` to the view. The `value` will be displayed in the
status bar, in a comma separated list of all status values, ordered by
key. Setting the `value` to `“”` will clear the status.
get\_status(*key: [str](#sublime.TextChange.str)*) → [str](#sublime.TextChange.str)
: Returns:
: The previous assigned value associated with the given `key`, if any.
See [`set_status()`](#sublime.View.set_status).
erase\_status(*key: [str](#sublime.TextChange.str)*)
: Clear the status associated with the provided `key`.
extract\_completions(*prefix: [str](#sublime.TextChange.str)*, *tp: [Point](#sublime.Point) = -1*) → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)]
: Get a list of word-completions based on the contents of the view.
Parameters:
: `prefix`
: The prefix to filter words by.
`tp`
: The [`Point`](#sublime.Point) by which to weigh words. Closer words are preferred.
command\_history(*index: [int](https://docs.python.org/3/builtins/functions.html#int)*, *modifying\_only=False*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](#sublime.TextChange.str), [CommandArgs](#sublime.CommandArgs), [int](https://docs.python.org/3/builtins/functions.html#int)]
: Get info on previous run commands stored in the undo/redo stack.
Parameters:
: `index`
: The offset into the undo/redo stack. Positive values for index
indicate to look in the redo stack for commands.
`modifying_only`
: Whether only commands that modify the text buffer are considered.
Returns:
: The command name, command arguments and repeat count for the history
entry. If the undo/redo history doesn’t extend far enough, then
`(None, None, 0)` will be returned.
overwrite\_status() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: The overwrite status, which the user normally toggles via the
insert key.
set\_overwrite\_status(*value: [bool](https://docs.python.org/3/builtins/functions.html#bool)*)
: Set the overwrite status. See [`overwrite_status()`](#sublime.View.overwrite_status).
: Show a popup menu at the caret, for selecting an item in a list.
Parameters:
: `items`
: The list of entries to show in the list.
`on_done`
: Called once with the index of the selected item. If the
popup was cancelled `-1` is passed instead.
`flags`
: must be `0`, currently unused.
show\_popup(*content: [str](#sublime.TextChange.str)*, *flags=PopupFlags.NONE*, *location: [Point](#sublime.Point) = -1*, *max\_width: [DIP](#sublime.DIP) = 320*, *max\_height: [DIP](#sublime.DIP) = 240*, *on\_navigate: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[str](#sublime.TextChange.str)], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *on\_hide: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*)
: Show a popup displaying HTML content.
Parameters:
: `content`
: The HTML content to display.
`flags`
: Flags controlling popup behavior. See [`PopupFlags`](#sublime.PopupFlags).
`location`
: The [`Point`](#sublime.Point) at which to display the popup. If `-1`
the popup is shown at the current postion of the caret.
`max_width`
: The maximum width of the popup.
`max_height`
: The maximum height of the popup.
`on_navigate`
: Called when a link is clicked in the popup. Passed the value of the
`href` attribute of the clicked link.
`on_hide`
: Called when the popup is hidden.
update\_popup(*content: [str](#sublime.TextChange.str)*)
: Update the content of the currently visible popup.
is\_popup\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether a popup is currently shown.
hide\_popup()
: Hide the current popup.
is\_auto\_complete\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether the auto-complete menu is currently visible.
preserve\_auto\_complete\_on\_focus\_lost()
4073
: Sets the auto complete popup state to be preserved the next time the
[`View`](#sublime.View) loses focus. When the [`View`](#sublime.View) regains focus, the auto complete
window will be re-shown, with the previously selected entry
pre-selected.
export\_to\_html(*regions: [Region](#sublime.Region) | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Region](#sublime.Region)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *minihtml=False*, *enclosing\_tags=False*, *font\_size=True*, *font\_family=True*)
4092
: Generates an HTML string of the current view contents, including styling
for syntax highlighting.
Parameters:
: `regions`
: The region(s) to export. By default the whole view is exported.
`minihtml`
: Whether the exported HTML should be compatible with [minihtml Reference](https://www.sublimetext.com/docs/minihtml.html).
`enclosing_tags`
: Whether a `<div>` with base-styling is added. Note that
without this no background color is set.
`font_size`
: Whether to include the font size in the top level styling. Only
applies when `enclosing_tags` is `True`.
`font_family`
: Whether to include the font family in the top level styling. Only
applies when `enclosing_tags` is `True`.
clear\_undo\_stack()
4114
: Clear the undo/redo stack.
class sublime.Buffer 4081
: Bases: object
Represents a text buffer. Multiple [`View`](#sublime.View) objects may share the same buffer.
id() → [int](https://docs.python.org/3/builtins/functions.html#int)
4083
: Returns a number that uniquely identifies this buffer.
file\_name() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
4083
: The full name file the file associated with the buffer, or `None` if
it doesn’t exist on disk.
views() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[View](#sublime.View)]
: Returns a list of all views that are associated with this buffer.
primary\_view() → [View](#sublime.View)
: The primary view associated with this buffer.
class sublime.Settings
: Bases: object
A `dict` like object that a settings hierarchy.
\_\_getitem\_\_(*key: [str](#sublime.TextChange.str)*) → [Value](#sublime.Value)
4023 3.8
: Returns the named setting.
\_\_setitem\_\_(*key: [str](#sublime.TextChange.str)*, *value: [Value](#sublime.Value)*)
4023 3.8
: Set the named `key` to the provided `value`.
\_\_delitem\_\_(*key: [str](#sublime.TextChange.str)*)
4078 3.8
: Deletes the provided `key` from the setting. Note that a parent
setting may also provide this key, thus deleting may not entirely
remove a key.
\_\_contains\_\_(*key: [str](#sublime.TextChange.str)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4023 3.8
: Returns whether the provided `key` is set.
to\_dict() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]
4078 3.8
: Return the settings as a dict. This is not very fast.
setdefault(*key: [str](#sublime.TextChange.str)*, *value: [Value](#sublime.Value)*) → [Value](#sublime.Value)
4023 3.8
: Returns the value associated with the provided `key`. If it’s not
present the provided `value` is assigned to the `key` and then
returned.
update(*other: [Mapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping)[[str](#sublime.TextChange.str), [Value](#sublime.Value)] | [Iterable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]] = ()*, */*, *\*\*kwargs*)
4078 3.8
: Update the settings from the provided argument(s).
Accepts:
- A `dict` or other implementation of `collections.abc.Mapping`.
- An object with a `keys()` method.
- An object that iterates over key/value pairs
- Keyword arguments, ie. `update(**kwargs)`.
get(*key: [str](#sublime.TextChange.str)*, *default: [Value](#sublime.Value) = None*) → [Value](#sublime.Value)
: Same as [`__getitem__`](#sublime.Settings.__getitem__).
has(*key: [str](#sublime.TextChange.str)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Same as [`__contains__`](#sublime.Settings.__contains__).
set(*key: [str](#sublime.TextChange.str)*, *value: [Value](#sublime.Value)*)
: Same as [`__setitem__`](#sublime.Settings.__setitem__).
erase(*key: [str](#sublime.TextChange.str)*)
: Same as [`__delitem__`](#sublime.Settings.__delitem__).
add\_on\_change(*tag: [str](#sublime.TextChange.str)*, *callback: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[], [None](https://docs.python.org/3/builtins/constants.html#None)]*)
: Register a callback to be run whenever a setting is changed.
Parameters:
: `tag`
: A string associated with the callback. For use with
[`clear_on_change`](#sublime.Settings.clear_on_change).
`callback`
: A callable object to be run when a setting is changed.
clear\_on\_change(*tag: [str](#sublime.TextChange.str)*)
: Remove all callbacks associated with the provided `tag`. See
[`add_on_change`](#sublime.Settings.add_on_change).
class sublime.Phantom
: Bases: object
Represents an [minihtml Reference](https://www.sublimetext.com/docs/minihtml.html)-based decoration to display non-editable content
interspersed in a [`View`](#sublime.View). Used with [`PhantomSet`](#sublime.PhantomSet) to actually add the
phantoms to the [`View`](#sublime.View). Once a [`Phantom`](#sublime.Phantom) has been constructed and added to
the [`View`](#sublime.View), changes to the attributes will have no effect.
region: [Region](#sublime.Region)
: The [`Region`](#sublime.Region) associated with the phantom. The phantom is displayed at
the start of the [`Region`](#sublime.Region).
content: [str](#sublime.TextChange.str)
: The HTML content of the phantom.
layout: [PhantomLayout](#sublime.PhantomLayout)
: How the phantom should be placed relative to the `region`.
on\_navigate: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[str](#sublime.TextChange.str)], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None)
: Called when a link in the HTML is clicked. The value of the `href`
attribute is passed.
to\_tuple() → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Point](#sublime.Point), [Point](#sublime.Point)], [str](#sublime.TextChange.str), [PhantomLayout](#sublime.PhantomLayout), [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[str](#sublime.TextChange.str)], [None](https://docs.python.org/3/builtins/constants.html#None)] | [None](https://docs.python.org/3/builtins/constants.html#None)]
: Returns a tuple of this phantom containing the region, content, layout
and callback.
Use this to uniquely identify a phantom in a set or similar. Phantoms
can’t be used for that directly as they are mutable.
class sublime.PhantomSet
: Bases: object
A collection that manages [`Phantom`](#sublime.Phantom) objects and the process of adding them,
updating them and removing them from a [`View`](#sublime.View).
\_\_init\_\_(*view: [View](#sublime.View)*, *key=''*)
view: [View](#sublime.View)
: The [`View`](#sublime.View) the phantom set is attached to.
key: [str](#sublime.TextChange.str)
: A string used to group the phantoms together.
update(*phantoms: [Iterable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable)[[Phantom](#sublime.Phantom)]*)
: Update the set of phantoms. If the [`Phantom.region`](#sublime.Phantom.region) of existing phantoms
have changed they will be moved; new phantoms are added and ones not
present are removed.
class sublime.Html
: Bases: object
Used to indicate that a string is formatted as HTML. See
[`CommandInputHandler.preview()`](#sublime_plugin.CommandInputHandler.preview).
class sublime.CompletionList 4050
: Bases: object
Represents a list of completions, some of which may be in the process of
being asynchronously fetched.
\_\_init\_\_(*completions: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[CompletionValue](#sublime.CompletionValue)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *flags=AutoCompleteFlags.NONE*)
: Parameters:
: `completions`
: If `None` is passed, the method [`set_completions()`](#sublime.CompletionList.set_completions) must be called
before the completions will be displayed to the user.
`flags`
: Flags controlling auto-complete behavior. See [`AutoCompleteFlags`](#sublime.AutoCompleteFlags).
set\_completions(*completions: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[CompletionValue](#sublime.CompletionValue)]*, *flags=AutoCompleteFlags.NONE*)
: Sets the list of completions, allowing the list to be displayed to the
user.
This function is thread-safe. If you’re generating a lot of
completions you’re encouraged to call this function from a
background thread to avoid blocking the UI.
4184
class sublime.CompletionItem 4050
: Bases: object
Represents an available auto-completion item.
trigger: [str](#sublime.TextChange.str)
: Text to match against the user’s input.
annotation: [str](#sublime.TextChange.str)
: A hint to draw to the right-hand side of the trigger.
completion: [str](#sublime.TextChange.str)
: Text to insert if the completion is specified. If empty the [`trigger`](#sublime.CompletionItem.trigger)
will be inserted instead.
completion\_format: [CompletionFormat](#sublime.CompletionFormat)
: The format of the completion. See [`CompletionFormat`](#sublime.CompletionFormat).
kind: [Kind](#sublime.Kind)
: The kind of the completion. See [`Kind`](#sublime.Kind).
details: [str](#sublime.TextChange.str)
4073
: An optional [minihtml Reference](https://www.sublimetext.com/docs/minihtml.html) description of the completion, shown in the
detail pane at the bottom of the auto complete window.
classmethod snippet\_completion(*trigger: [str](#sublime.TextChange.str)*, *snippet: [str](#sublime.TextChange.str)*, *annotation=''*, *kind: [Kind](#sublime.Kind) = (KindId.SNIPPET, 's', 'Snippet')*, *details=''*) → [CompletionItem](#sublime.CompletionItem)
: Specialized constructor for snippet completions. The [`completion_format`](#sublime.CompletionItem.completion_format)
is always [`CompletionFormat.SNIPPET`](#sublime.CompletionFormat.SNIPPET).
classmethod command\_completion(*trigger: [str](#sublime.TextChange.str)*, *command: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs) = None*, *annotation=''*, *kind: [Kind](#sublime.Kind) = (KindId.AMBIGUOUS, '', '')*, *details=''*) → [CompletionItem](#sublime.CompletionItem)
: Specialized constructor for command completions. The [`completion_format`](#sublime.CompletionItem.completion_format)
is always [`CompletionFormat.COMMAND`](#sublime.CompletionFormat.COMMAND).
sublime.list_syntaxes() → list[Syntax] : list all known syntaxes.
Returns a list of Syntax.
sublime.syntax_from_path(path: str) → Syntax | None : Get the syntax for a specific path.
Returns a Syntax or None.
sublime.find_syntax_by_name(name: str) → list[Syntax] : Find syntaxes with the specified name.
Name must match exactly. Return a list of Syntax.
sublime.find_syntax_by_scope(scope: str) → list[Syntax] : Find syntaxes with the specified scope.
Scope must match exactly. Return a list of Syntax.
sublime.find_syntax_for_file(path: str, first_line='') → Syntax | None : Find the syntax to use for a path.
Uses the file extension, various application settings and optionally the
first line of the file to pick the right syntax for the file.
Returns a Syntax.
class sublime.Syntax 4081
: Bases: object
Contains information about a syntax.
path: [str](#sublime.TextChange.str)
: The packages path to the syntax file.
name: [str](#sublime.TextChange.str)
: The name of the syntax.
hidden: [bool](https://docs.python.org/3/builtins/functions.html#bool)
: If the syntax is hidden from the user.
scope: [str](#sublime.TextChange.str)
: The base scope name of the syntax.
class sublime.QuickPanelItem 4083
: Bases: object
Represents a row in the quick panel, shown via [`Window.show_quick_panel()`](#sublime.Window.show_quick_panel).
trigger: [str](#sublime.TextChange.str)
: Text to match against user’s input.
details: [str](#sublime.TextChange.str) | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)] | [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](#sublime.TextChange.str)]
: A [minihtml Reference](https://www.sublimetext.com/docs/minihtml.html) string or list of strings displayed below the trigger.
annotation: [str](#sublime.TextChange.str)
: Hint to draw to the right-hand side of the row.
kind: [Kind](#sublime.Kind)
: The kind of the item. See [`Kind`](#sublime.Kind).
class sublime.ListInputItem 4095
: Bases: object
Represents a row shown via [`ListInputHandler`](#sublime_plugin.ListInputHandler).
text: [str](#sublime.TextChange.str)
: Text to match against the user’s input.
value: Any
: A [`Value`](#sublime.Value) passed to the command if the row is selected.
details: [str](#sublime.TextChange.str) | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)] | [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](#sublime.TextChange.str)]
: A [minihtml Reference](https://www.sublimetext.com/docs/minihtml.html) string or list of strings displayed below the trigger.
annotation: [str](#sublime.TextChange.str)
: Hint to draw to the right-hand side of the row.
kind: [Kind](#sublime.Kind)
: The kind of the item. See [`Kind`](#sublime.Kind).
class sublime.SymbolRegion 4085
: Bases: object
Contains information about a [`Region`](#sublime.Region) of a [`View`](#sublime.View) that contains a symbol.
name: [str](#sublime.TextChange.str)
: The name of the symbol.
region: [Region](#sublime.Region)
: The location of the symbol within the [`View`](#sublime.View).
syntax: [str](#sublime.TextChange.str)
: The name of the syntax for the symbol.
type: [SymbolType](#sublime.SymbolType)
: The type of the symbol. See [`SymbolType`](#sublime.SymbolType).
kind: [Kind](#sublime.Kind)
: The kind of the symbol. See [`Kind`](#sublime.Kind).
class sublime.SymbolLocation 4085
: Bases: object
Contains information about a file that contains a symbol.
path: [str](#sublime.TextChange.str)
: The filesystem path to the file containing the symbol.
display\_name: [str](#sublime.TextChange.str)
: The project-relative path to the file containing the symbol.
row: [int](https://docs.python.org/3/builtins/functions.html#int)
: The row of the file the symbol is contained on.
col: [int](https://docs.python.org/3/builtins/functions.html#int)
: The column of the row that the symbol is contained on.
syntax: [str](#sublime.TextChange.str)
: The name of the syntax for the symbol.
type: [SymbolType](#sublime.SymbolType)
: The type of the symbol. See [`SymbolType`](#sublime.SymbolType).
kind: [Kind](#sublime.Kind)
: The kind of the symbol. See [`Kind`](#sublime.Kind).
sublime_plugin Module
class sublime_plugin.CommandInputHandler
: Bases: object
name() → [str](#sublime.TextChange.str)
: The command argument name this input handler is editing. Defaults to
`foo_bar` for an input handler named `FooBarInputHandler`.
placeholder() → [str](#sublime.TextChange.str)
: Placeholder text is shown in the text entry box before the user has
entered anything. Empty by default.
initial\_text() → [str](#sublime.TextChange.str)
: Initial text shown in the text entry box. Empty by default.
initial\_selection() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]]
4081
: A list of 2-element tuples, defining the initially selected parts of the
initial text.
preview(*text: [str](#sublime.TextChange.str)*) → [str](#sublime.TextChange.str) | [Html](#sublime.Html)
: Called whenever the user changes the text in the entry box. The returned
value (either plain text or HTML) will be shown in the preview area of
the *Command Palette*.
validate(*text: [str](#sublime.TextChange.str)*, *event: [Event](#sublime.Event) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Called whenever the user presses enter in the text entry box.
Return `False` to disallow the current value.
Parameters:
: `event`
: Only passed when [`want_event`](#sublime_plugin.CommandInputHandler.want_event) returns `True`.
cancel()
: Called when the input handler is canceled, either by the user pressing
backspace or escape.
confirm(*text: [str](#sublime.TextChange.str)*, *event: [Event](#sublime.Event) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*)
: Called when the input is accepted, after the user has pressed enter and
the text has been validated.
Parameters:
: `event`
: Only passed when [`want_event`](#sublime_plugin.CommandInputHandler.want_event) returns `True`.
next\_input(*args*) → [CommandInputHandler](#sublime_plugin.CommandInputHandler) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Return the next input after the user has completed this one. May return
`None` to indicate no more input is required, or
[`sublime_plugin.BackInputHandler()`](#sublime_plugin.BackInputHandler) to indicate that the input handler
should be popped off the stack instead.
want\_event() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
4096
: Whether the [`validate()`](#sublime_plugin.CommandInputHandler.validate) and [`confirm()`](#sublime_plugin.CommandInputHandler.confirm) methods should received a
second [`Event`](#sublime.Event) parameter. Returns `False` by default.
class sublime_plugin.BackInputHandler
: Bases: CommandInputHandler
class sublime_plugin.TextInputHandler
: Bases: CommandInputHandler
TextInputHandlers can be used to accept textual input in the *Command
Palette*. Return a subclass of this from [`Command.input()`](#sublime_plugin.Command.input).
*For an input handler to be shown to the user, the command returning the
input handler MUST be made available in the Command Palette by adding the
command to a Default.sublime-commands file.*
description(*text: [str](#sublime.TextChange.str)*) → [str](#sublime.TextChange.str)
: The text to show in the *Command Palette* when this input handler is not
at the top of the input handler stack. Defaults to the text the user
entered.
class sublime_plugin.ListInputHandler
: Bases: CommandInputHandler
ListInputHandlers can be used to accept a choice input from a list items in
the *Command Palette*. Return a subclass of this from [`Command.input()`](#sublime_plugin.Command.input).
*For an input handler to be shown to the user, the command returning the
input handler MUST be made available in the Command Palette by adding the
command to a Default.sublime-commands file.*
list\_items() → [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)] | [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](#sublime.TextChange.str)], [int](https://docs.python.org/3/builtins/functions.html#int)] | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]] | [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](#sublime.TextChange.str), [Value](#sublime.Value)]], [int](https://docs.python.org/3/builtins/functions.html#int)] | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[sublime.ListInputItem](#sublime.ListInputItem)] | [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[list](https://docs.python.org/3/builtins/stdtypes.html#list)[[sublime.ListInputItem](#sublime.ListInputItem)], [int](https://docs.python.org/3/builtins/functions.html#int)]
: This method should return the items to show in the list.
The returned value may be a `list` of item, or a 2-element `tuple`
containing a list of items, and an `int` index of the item to
pre-select.
The each item in the list may be one of:
- A string used for both the row text and the value passed to the
command
- A 2-element tuple containing a string for the row text, and a [`Value`](#sublime.Value)
to pass to the command
- A [`sublime.ListInputItem`](#sublime.ListInputItem) object
4095
description(*value: [Value](#sublime.Value)*, *text: [str](#sublime.TextChange.str)*) → [str](#sublime.TextChange.str)
: The text to show in the *Command Palette* when this input handler is not
at the top of the input handler stack. Defaults to the text of the list
item the user selected.
class sublime_plugin.Command
: Bases: object
name() → [str](#sublime.TextChange.str)
: Return the name of the command. By default this is derived from the name
of the class.
is\_enabled() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Return whether the command is able to be run at this time. Command
arguments are passed as keyword arguments. The default implementation
simply always returns `True`.
is\_visible() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Return whether the command should be shown in the menu at this time.
Command arguments are passed as keyword arguments. The default
implementation always returns `True`.
is\_checked() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Return whether a checkbox should be shown next to the menu item. Command
arguments are passed as keyword arguments. The .sublime-menu
file must have the `“checkbox”` key set to `true` for this to
be used.
description() → [str](#sublime.TextChange.str) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Return a description of the command with the given arguments. Command
arguments are passed as keyword arguments. Used in the menu, if no
caption is provided. Return `None` to get the default description.
want\_event() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Return whether to receive an [`Event`](#sublime.Event) argument when the command is
triggered by a mouse action. The event information allows commands to
determine which portion of the view was clicked on. The default
implementation returns `False`.
input(*args: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)*) → [CommandInputHandler](#sublime_plugin.CommandInputHandler) | [None](https://docs.python.org/3/builtins/constants.html#None)
3154
: If this returns something other than `None`, the user will be
prompted for an input before the command is run in the *Command
Palette*.
input\_description() → [str](#sublime.TextChange.str)
3154
: Allows a custom name to be show to the left of the cursor in the input
box, instead of the default one generated from the command name.
run(*\*\*kwargs: [Value](#sublime.Value)*)
: Called when the command is run. Command arguments are passed as keyword
arguments.
class sublime_plugin.ApplicationCommand
: Bases: Command
A [`Command`](#sublime_plugin.Command) instantiated just once.
run(*\*\*kwargs: [Value](#sublime.Value)*)
: Called when the command is run. Command arguments are passed as keyword
arguments.
class sublime_plugin.WindowCommand
: Bases: Command
A [`Command`](#sublime_plugin.Command) instantiated once per window. The [`Window`](#sublime.Window) object may be
retrieved via [`self.window`](#sublime_plugin.WindowCommand.window).
window: [Window](#sublime.Window)
: The [`Window`](#sublime.Window) this command is attached to.
run(*\*\*kwargs: [Value](#sublime.Value)*)
: Called when the command is run. Command arguments are passed as keyword
arguments.
class sublime_plugin.TextCommand
: Bases: Command
A [`Command`](#sublime_plugin.Command) instantiated once per [`View`](#sublime.View). The [`View`](#sublime.View) object may be retrieved
via [`self.view`](#sublime_plugin.TextCommand.view).
view: [View](#sublime.View)
: The [`View`](#sublime.View) this command is attached to.
run(*edit: [sublime.Edit](#sublime.Edit)*, *\*\*kwargs: [Value](#sublime.Value)*)
: Called when the command is run. Command arguments are passed as keyword
arguments.
class sublime_plugin.EventListener
: Bases: object
on\_init(*views: List[[View](#sublime.View)]*)
4050
: Called once with a list of views that were loaded before the
EventListener was instantiated
on\_exit()
4050
: Called once after the API has shut down, immediately before the
plugin\_host process exits
on\_new(*view: [View](#sublime.View)*)
: Called when a new file is created.
on\_new\_async(*view: [View](#sublime.View)*)
: Called when a new buffer is created. Runs in a separate thread, and does
not block the application.
on\_associate\_buffer(*buffer: [View](#sublime.View)*)
4084
: Called when a buffer is associated with a file. buffer will be a Buffer
object.
on\_associate\_buffer\_async(*buffer: [View](#sublime.View)*)
4084
: Called when a buffer is associated with file. Runs in a separate thread,
and does not block the application. buffer will be a Buffer object.
on\_clone(*view: [View](#sublime.View)*)
: Called when a view is cloned from an existing one.
on\_clone\_async(*view: [View](#sublime.View)*)
: Called when a view is cloned from an existing one. Runs in a separate
thread, and does not block the application.
on\_load(*view: [View](#sublime.View)*)
: Called when the file is finished loading.
on\_load\_async(*view: [View](#sublime.View)*)
: Called when the file is finished loading. Runs in a separate thread, and
does not block the application.
on\_reload(*view: [View](#sublime.View)*)
4050
: Called when the View is reloaded.
on\_reload\_async(*view: [View](#sublime.View)*)
4050
: Called when the View is reloaded. Runs in a separate thread, and does
not block the application.
on\_revert(*view: [View](#sublime.View)*)
4050
: Called when the View is reverted.
on\_revert\_async(*view: [View](#sublime.View)*)
4050
: Called when the View is reverted. Runs in a separate thread, and does
not block the application.
on\_pre\_move(*view: [View](#sublime.View)*)
4050
: Called right before a view is moved between two windows or within a
window. Passed the View object.
on\_post\_move(*view: [View](#sublime.View)*)
4050
: Called right after a view is moved between two windows or within a
window. Passed the View object.
on\_post\_move\_async(*view: [View](#sublime.View)*)
4050
: Called right after a view is moved between two windows or within a
window. Passed the View object. Runs in a separate thread, and does not
block the application.
on\_pre\_close(*view: [View](#sublime.View)*)
: Called when a view is about to be closed. The view will still be in the
window at this point.
on\_close(*view: [View](#sublime.View)*)
: Called when a view is closed (note, there may still be other views into
the same buffer).
on\_pre\_save(*view: [View](#sublime.View)*)
: Called just before a view is saved.
on\_pre\_save\_async(*view: [View](#sublime.View)*)
: Called just before a view is saved. Runs in a separate thread, and does
not block the application.
on\_post\_save(*view: [View](#sublime.View)*)
: Called after a view has been saved.
on\_post\_save\_async(*view: [View](#sublime.View)*)
: Called after a view has been saved. Runs in a separate thread, and does
not block the application.
on\_modified(*view: [View](#sublime.View)*)
: Called after changes have been made to a view.
on\_modified\_async(*view: [View](#sublime.View)*)
: Called after changes have been made to a view. Runs in a separate
thread, and does not block the application.
on\_selection\_modified(*view: [View](#sublime.View)*)
: Called after the selection has been modified in a view.
on\_selection\_modified\_async(*view: [View](#sublime.View)*)
: Called after the selection has been modified in a view. Runs in a
separate thread, and does not block the application.
on\_activated(*view: [View](#sublime.View)*)
: Called when a view gains input focus.
on\_activated\_async(*view: [View](#sublime.View)*)
: Called when a view gains input focus. Runs in a separate thread, and
does not block the application.
on\_deactivated(*view: [View](#sublime.View)*)
: Called when a view loses input focus.
on\_deactivated\_async(*view: [View](#sublime.View)*)
: Called when a view loses input focus. Runs in a separate thread, and
does not block the application.
on\_hover(*view: [View](#sublime.View)*, *point: [Point](#sublime.Point)*, *hover\_zone: [HoverZone](#sublime.HoverZone)*)
: Called when the user’s mouse hovers over the view for a short period.
Parameters:
: `view`
: The view
`point`
: The closest point in the view to the mouse location. The mouse may
not actually be located adjacent based on the value of
`hover_zone`.
`hover_zone`
: Which element in Sublime Text the mouse has hovered over.
on\_query\_context(*view: [View](#sublime.View)*, *key: [str](#sublime.TextChange.str)*, *operator: [QueryOperator](#sublime.QueryOperator)*, *operand: [Value](#sublime.Value)*, *match\_all: [bool](https://docs.python.org/3/builtins/functions.html#bool)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Called when determining to trigger a key binding with the given context
key. If the plugin knows how to respond to the context, it should
return either True of False. If the context is unknown, it should
return None.
Parameters:
: `key`
: The context key to query. This generally refers to specific state
held by a plugin.
`operator`
: The operator to check against the operand; whether to check
equality, inequality, etc.
`operand`
: The value against which to check using the `operator`.
`match_all`
: This should be used if the context relates to the selections: does
every selection have to match(`match_all == True`), or is at
least one matching enough (`match_all == False`)?
Returns:
: `True` or `False` if the plugin handles this context key and it
either does or doesn’t match. If the context is unknown return
`None`.
on\_query\_completions(*view: [View](#sublime.View)*, *prefix: [str](#sublime.TextChange.str)*, *locations: List[[Point](#sublime.Point)]*) → [None](https://docs.python.org/3/builtins/constants.html#None) | List[[CompletionValue](#sublime.CompletionValue)] | [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[List[[CompletionValue](#sublime.CompletionValue)], [AutoCompleteFlags](#sublime.AutoCompleteFlags)] | [CompletionList](#sublime.CompletionList)
: Called whenever completions are to be presented to the user.
Parameters:
: `prefix`
: The text already typed by the user.
`locations`
: The list of points being completed. Since this method
is called for all completions no matter the syntax,
`self.view.match_selector(point, relevant_scope)`
should be called to determine if the point is
relevant.
Returns:
: A list of completions in one of the valid formats or `None` if no completions are provided.
on\_text\_command(*view: [View](#sublime.View)*, *command\_name: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs)*)
: Called when a text command is issued. The listener may return a
(command, arguments) tuple to rewrite the command, or `None` to run
the command unmodified.
on\_window\_command(*window: [Window](#sublime.Window)*, *command\_name: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs)*)
: Called when a window command is issued. The listener may return a
(command, arguments) tuple to rewrite the command, or `None` to run
the command unmodified.
on\_post\_text\_command(*view: [View](#sublime.View)*, *command\_name: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs)*)
: Called after a text command has been executed.
on\_post\_window\_command(*window: [Window](#sublime.Window)*, *command\_name: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs)*)
: Called after a window command has been executed.
on\_new\_window(*window: [Window](#sublime.Window)*)
4050
: Called when a window is created, passed the Window object.
on\_new\_window\_async(*window: [Window](#sublime.Window)*)
4050
: Called when a window is created, passed the Window object. Runs in a
separate thread, and does not block the application.
on\_pre\_close\_window(*window: [Window](#sublime.Window)*)
4050
: Called right before a window is closed, passed the Window object.
on\_new\_project(*window: [Window](#sublime.Window)*)
4050
: Called right after a new project is created, passed the Window object.
on\_new\_project\_async(*window: [Window](#sublime.Window)*)
4050
: Called right after a new project is created, passed the Window object.
Runs in a separate thread, and does not block the application.
on\_load\_project(*window: [Window](#sublime.Window)*)
4050
: Called right after a project is loaded, passed the Window object.
on\_load\_project\_async(*window: [Window](#sublime.Window)*)
4050
: Called right after a project is loaded, passed the Window object. Runs
in a separate thread, and does not block the application.
on\_pre\_save\_project(*window: [Window](#sublime.Window)*)
4050
: Called right before a project is saved, passed the Window object.
on\_post\_save\_project(*window: [Window](#sublime.Window)*)
4050
: Called right after a project is saved, passed the Window object.
on\_post\_save\_project\_async(*window: [Window](#sublime.Window)*)
4050
: Called right after a project is saved, passed the Window object. Runs in
a separate thread, and does not block the application.
on\_pre\_close\_project(*window: [Window](#sublime.Window)*)
: Called right before a project is closed, passed the Window object.
class sublime_plugin.ViewEventListener
: Bases: object
> A class that provides similar event handling to [`EventListener`](#sublime_plugin.EventListener), but bound
> to a specific view. Provides class method-based filtering to control what
> views objects are created for.
on\_load()
3155
: Called when the file is finished loading.
on\_load\_async()
3155
: Same as [`on_load`](#sublime_plugin.ViewEventListener.on_load) but runs in a separate thread, not blocking the
application.
on\_reload()
4050
: Called when the file is reloaded.
on\_reload\_async()
4050
: Same as [`on_reload`](#sublime_plugin.ViewEventListener.on_reload) but runs in a separate thread, not blocking the
application.
on\_revert()
4050
: Called when the file is reverted.
on\_revert\_async()
4050
: Same as [`on_revert`](#sublime_plugin.ViewEventListener.on_revert) but runs in a separate thread, not blocking the
application.
on\_pre\_move()
4050
: Called right before a view is moved between two windows or within a
window.
on\_post\_move()
4050
: Called right after a view is moved between two windows or within a
window.
on\_post\_move\_async()
4050
: Same as [`on_post_move`](#sublime_plugin.ViewEventListener.on_post_move) but runs in a separate thread, not blocking the
application.
on\_pre\_close()
3155
: Called when a view is about to be closed. The view will still be in the
window at this point.
on\_close()
3155
: Called when a view is closed (note, there may still be other views into
the same buffer).
on\_pre\_save()
3155
: Called just before a view is saved.
on\_pre\_save\_async()
3155
: Same as [`on_pre_save`](#sublime_plugin.ViewEventListener.on_pre_save) but runs in a separate thread, not blocking the
application.
on\_post\_save()
3155
: Called after a view has been saved.
on\_post\_save\_async()
3155
: Same as [`on_post_save`](#sublime_plugin.ViewEventListener.on_post_save) but runs in a separate thread, not blocking the
application.
on\_modified()
: Called after changes have been made to the view.
on\_modified\_async()
: Same as [`on_modified`](#sublime_plugin.ViewEventListener.on_modified) but runs in a separate thread, not blocking the
application.
on\_selection\_modified()
: Called after the selection has been modified in the view.
on\_selection\_modified\_async()
: Called after the selection has been modified in the view. Runs in a
separate thread, and does not block the application.
on\_activated()
: Called when a view gains input focus.
on\_activated\_async()
: Called when the view gains input focus. Runs in a separate thread, and
does not block the application.
on\_deactivated()
: Called when the view loses input focus.
on\_deactivated\_async()
: Called when the view loses input focus. Runs in a separate thread, and
does not block the application.
on\_hover(*point: [Point](#sublime.Point)*, *hover\_zone: [HoverZone](#sublime.HoverZone)*)
: Called when the user’s mouse hovers over the view for a short period.
Parameters:
: `point`
: The closest point in the view to the mouse location. The mouse may
not actually be located adjacent based on the value of
`hover_zone`.
`hover_zone`
: Which element in Sublime Text the mouse has hovered over.
on\_query\_context(*key: [str](#sublime.TextChange.str)*, *operator: [QueryOperator](#sublime.QueryOperator)*, *operand: [Value](#sublime.Value)*, *match\_all: [bool](https://docs.python.org/3/builtins/functions.html#bool)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Called when determining to trigger a key binding with the given context
key. If the plugin knows how to respond to the context, it should
return either True of False. If the context is unknown, it should
return None.
Parameters:
: `key`
: The context key to query. This generally refers to specific
state held by a plugin.
`operator`
: The operator to check against the operand; whether to
check equality, inequality, etc.
`operand`
: The value against which to check using the `operator`.
`match_all`
: This should be used if the context relates to the
selections: does every selection have to match
(`match_all == True`), or is at least one matching
enough (`match_all == False`)?
Returns:
: `True` or `False` if the plugin handles this context key
and it either does or doesn’t match. If the context is unknown
return `None`.
on\_query\_completions(*prefix: [str](#sublime.TextChange.str)*, *locations: List[[Point](#sublime.Point)]*) → [None](https://docs.python.org/3/builtins/constants.html#None) | List[[CompletionValue](#sublime.CompletionValue)] | [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[List[[CompletionValue](#sublime.CompletionValue)], [AutoCompleteFlags](#sublime.AutoCompleteFlags)] | [CompletionList](#sublime.CompletionList)
: Called whenever completions are to be presented to the user.
Parameters:
: `prefix`
: The text already typed by the user.
`locations`
: The list of points being completed. Since this method
is called for all completions no matter the syntax,
`self.view.match_selector(point, relevant_scope)`
should be called to determine if the point is
relevant.
Returns:
: A list of completions in one of the valid formats or `None` if no completions are provided.
on\_text\_command(*command\_name: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs)*) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](#sublime.TextChange.str), [CommandArgs](#sublime.CommandArgs)]
3155
: Called when a text command is issued. The listener may return a
`` (command, arguments)`` tuple to rewrite the command, or `None` to
run the command unmodified.
on\_post\_text\_command(*command\_name: [str](#sublime.TextChange.str)*, *args: [CommandArgs](#sublime.CommandArgs)*)
: Called after a text command has been executed.
classmethod is\_applicable(*settings: [Settings](#sublime.Settings)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether this listener should apply to a view with the given [`Settings`](#sublime.Settings).
classmethod applies\_to\_primary\_view\_only() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether this listener should apply only to the primary view
for a file or all of its clones as well.
class sublime_plugin.TextChangeListener 4081
: Bases: object
A class that provides event handling about text changes made to a specific
Buffer. Is separate from [`ViewEventListener`](#sublime_plugin.ViewEventListener) since multiple views can
share a single buffer.
on\_text\_changed(*changes: List[[TextChange](#sublime.TextChange)]*)
: Called once after changes has been made to a buffer, with detailed
information about what has changed.
on\_text\_changed\_async(changes: List[TextChange]):
: Same as [`on_text_changed`](#sublime_plugin.TextChangeListener.on_text_changed) but runs in a separate thread, not blocking
the application.
on\_revert()
: Called when the buffer is reverted.
A revert does not trigger text changes. If the contents of the buffer
are required here use [`View.substr`](#sublime.View.substr).
on\_revert\_async()
: Same as [`on_revert`](#sublime_plugin.TextChangeListener.on_revert) but runs in a separate thread, not blocking the
application.
on\_reload()
: Called when the buffer is reloaded.
A reload does not trigger text changes. If the contents of the buffer
are required here use [`View.substr`](#sublime.View.substr).
on\_reload\_async()
: Same as [`on_reload`](#sublime_plugin.TextChangeListener.on_reload) but runs in a separate thread, not blocking the
application.
classmethod is\_applicable(*buffer: [Buffer](#sublime.Buffer)*) → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: Whether this listener should apply to the provided buffer.
detach()
: Remove this listener from the buffer.
Async callbacks may still be called after this, as they are queued
separately.
Raises [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError):
: if the listener is not attached.
attach(*buffer: [Buffer](#sublime.Buffer)*)
: Attach this listener to a buffer.
Raises [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError):
: if the listener is already attached.
is\_attached() → [bool](https://docs.python.org/3/builtins/functions.html#bool)
: Returns:
: whether the listener is receiving events from a buffer. May not be
called from `__init__`.
Sublime Merge
