Sublime Text Documentation
website·Indexed 35 days ago
https://docs.sublimetext.ioOfficial documentation for the Sublime Text text editor, covering basic concepts, customization of settings and color schemes, and extensibility via the Python API, plugins, and syntax definitions. Includes detailed guides on Package Control, keyboard shortcuts for Windows, Linux, and OSX, and example setups for languages like Julia and TypeScript.
What's inside Sublime Text
- Sublime Text is a cross-platform text editor supported on macOS, Windows, and Linux. It is designed for both code and prose, focusing on speed and the automation of repetitive tasks. While it provides a functional basic feature set out of the box, it can be extended into a full IDE using community-developed third-party packages. These packages provide syntax highlighting, snippets, and automation powered by Python plugins.
Overview of Input Handlers in Sublime Text
Input handlers allow plugins to query users for one or more parameters via the Command Palette. They replace the older
Window.show_input_panelandWindow.show_quick_panelmethods to provide a unified user experience.There are two primary types of input handlers:
- Text Input Handlers: Accept arbitrary text input.
- List Input Handlers: Provide a list of options for the user to select from. These can handle any JSON-serializable value accompanied by a caption.
Overview of legacy .tmTheme color schemes
Sublime Text supports a legacy color scheme format using the.tmThemeextension (inherited from TextMate). Color schemes define the colors for the editor area (background, foreground, selection, caret, etc.), which is distinct from 'themes' that define the overall UI layout. For the modern.sublime-color-schemeformat introduced in Sublime Text 3.1, refer to the official current documentation.Overview of Sublime Text Syntax Definitions
Syntax definitions enable language awareness and syntax highlighting in Sublime Text by dividing text into named regions called 'scopes'. They consist of regular expressions (rules) paired with dot-separated scope names. When a regular expression matches, the corresponding scope name is attached to that text region. These scopes are used by color schemes for styling and by snippets or key bindings to provide contextual functionality.Overview of Legacy .tmLanguage Syntax Definitions
Sublime Text supports the legacy.tmLanguageformat (inherited from TextMate), which uses Plist files. While a newer.sublime-syntaxformat is recommended for Sublime Text 3.0 (Build 3084) and later,.tmLanguageis used for compatibility with older versions or other editors. Additionally, files with the.hidden-tmLanguageextension are recognized by Sublime Text and used by plugins (e.g., 'Find in Files') but cannot be selected by the user or included via import statements in other definitions.Restrict package releases by platform
Use theplatformskey to specify which operating systems a release is valid for. If omitted, the package is assumed compatible with all platforms. Valid identifiers include*,windows,osx, andlinux. Architecture suffixes like-x64or-x32are also supported.{ "details": "https://github.com/wbond/sublime_alignment", "releases": [ { "platforms": ["osx", "linux"], "sublime_text": "*", "tags": "posix-" }, { "platforms": "windows", "sublime_text": "*", "tags": "win32-" } ] }Manage the project Sidebar
The sidebar provides a project overview and basic file management via its context menu. Files opened from the sidebar create 'semi-transient' views (indicated by italicized tab titles); opening a new semi-transient view in the same pane automatically closes the previous one.Description Shortcut Toggle side bar Ctrl K, Ctrl B Give focus to the side bar Ctrl 0 Return focus to the view Esc Navigate side bar Arrow keys Develop Sublime Text plugins with Python
Sublime Text is extended using Python plugins. Plugins are created by defining Python classes that derive from specific command classes provided by thesublime_pluginmodule. At the time of documentation, Sublime Text uses Python 3.3.Understand Sublime Text extensibility and resources
Sublime Text is programmable via a Python API. Most customizations are handled through 'resources'—configuration files stored within thePackagesfolder. These files typically use JSON, XML, or YAML formats, while advanced extensibility is implemented via Python source code files. A 'package' is a folder or zip archive that groups related resources together.Understand the Package Control distribution hierarchy
Package Control uses a three-tier hierarchy to discover and distribute packages: Channels → Repositories → Packages.
- Channels: JSON files hosted at a URL that contain a list of repository URLs. When a user installs a package, the client queries these channels to find relevant repositories.
- Repositories: JSON files hosted at a URL that contain a list of packages. These files define metadata such as compatible platforms (Windows, macOS, Linux), compatible Sublime Text versions, labels, and URLs.
- Packages: The actual code, typically hosted on GitHub, GitLab, or Bitbucket.
Use built-in TypeScript syntax support in Sublime Text 4
Sublime Text 4 includes built-in TypeScript syntax support, providing high-quality syntax highlighting and core features such as completions and 'Go to Definition' without requiring additional third-party syntax packages.Invoke Sublime Text commands via Python plugins
Commands in Sublime Text are identified by snake_case names (e.g.,hot_exit). They can be executed from Python plugins using therun_commandmethod on a view or window object. Commands accept an optional dictionary of arguments where keys are strings and values are JSON-compatible types.# Run a command on the current view to go to a specific line view.run_command("goto_line", {"line": 10}) # Insert a snippet into the view view.run_command('insert_snippet', {"contents": "<$SELECTION>"}) # Run a command on the window object view.window().run_command("prompt_select_project")