Sublime Text Documentation

website·Indexed 35 days ago

https://docs.sublimetext.io

Official 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.

Tokens
39K
Snippets
160
Records
299
Agent score
70%

What's inside Sublime Text

  1. Overview of 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.
  2. 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_panel and Window.show_quick_panel methods to provide a unified user experience.

    There are two primary types of input handlers:

    1. Text Input Handlers: Accept arbitrary text input.
    2. 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.
  3. Overview of legacy .tmTheme color schemes

    Sublime Text supports a legacy color scheme format using the .tmTheme extension (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-scheme format introduced in Sublime Text 3.1, refer to the official current documentation.
  4. 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.
  5. Overview of Legacy .tmLanguage Syntax Definitions

    Sublime Text supports the legacy .tmLanguage format (inherited from TextMate), which uses Plist files. While a newer .sublime-syntax format is recommended for Sublime Text 3.0 (Build 3084) and later, .tmLanguage is used for compatibility with older versions or other editors. Additionally, files with the .hidden-tmLanguage extension 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.
  6. Restrict package releases by platform

    Use the platforms key 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, and linux. Architecture suffixes like -x64 or -x32 are also supported.
    {
    	"details": "https://github.com/wbond/sublime_alignment",
    	"releases": [
    		{
    			"platforms": ["osx", "linux"],
    			"sublime_text": "*",
    			"tags": "posix-"
    		},
    		{
    			"platforms": "windows",
    			"sublime_text": "*",
    			"tags": "win32-"
    		}
    	]
    }
  7. 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.
    DescriptionShortcut
    Toggle side barCtrl K, Ctrl B
    Give focus to the side barCtrl 0
    Return focus to the viewEsc
    Navigate side barArrow keys
  8. 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 the sublime_plugin module. At the time of documentation, Sublime Text uses Python 3.3.
  9. Understand Sublime Text extensibility and resources

    Sublime Text is programmable via a Python API. Most customizations are handled through 'resources'—configuration files stored within the Packages folder. 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.
  10. 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.
  11. 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.
  12. 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 the run_command method 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")