Sublime Text
Development Tool
Sublime Text
Overview
Sublime Text is a lightweight and feature-rich text editor developed by Sublime HQ Pty Ltd. It is beloved by many developers for its fast performance, intuitive interface, and extensive customization capabilities.
Details
Sublime Text was released in 2008, with Sublime Text 4 currently being the latest version. Developed in C++ and Python, it offers cross-platform support for Windows, macOS, and Linux. Despite being lightweight, it provides powerful features and is particularly known for its high speed and responsiveness.
Sublime Text's greatest strengths include the "Goto Anything" feature, multi-cursor and multi-selection capabilities, minimap display, split editing, command palette, and powerful search and replace functions. The rich plugin ecosystem through Package Control enables support for any programming language and development workflow.
It includes all features expected from a modern text editor: syntax highlighting, code completion, snippet functionality, code folding, and Vintage mode (Vim-style editing). JSON-based configuration files allow fine-grained customization to optimize the editor according to user preferences.
Advantages and Disadvantages
Advantages
- Extremely Lightweight: Very lightweight by default with fast startup and operation
- Multi-cursor: High editing efficiency through simultaneous editing at multiple locations
- Minimap: Efficient navigation through top-down view of entire file
- Rich Keyboard Shortcuts: Most actions can be performed via keyboard
- Column Selection: Versatile editing through flexible selection methods
- Vintage Mode: Built-in Vim-style editing functionality
- Package Control: Feature extension through rich plugins
Disadvantages
- Paid License: Purchase required for continued use (trial version has limitations)
- Proprietary: Not open source, source code is closed
- Purchase Prompts: Regular purchase reminder dialogs when unlicensed
- No Printing: File printing functionality is not provided
- Limited Integration: IDE-level integrated development features are limited
- Plugin Dependency: Advanced features require plugin installation
- Update Frequency: Long intervals between major updates
Key Links
- Sublime Text Official Site
- Sublime Text Documentation
- Package Control
- Sublime Text Community
- Sublime Text Blog
Code Examples
Basic Configuration
// Preferences.sublime-settings - Basic Settings
{
"theme": "Adaptive.sublime-theme",
"color_scheme": "Monokai.sublime-color-scheme",
"font_face": "Fira Code",
"font_size": 12,
"font_options": ["gray_antialias", "subpixel_antialias"],
"line_numbers": true,
"rulers": [80, 120],
"word_wrap": true,
"wrap_width": 80,
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
"show_encoding": true,
"show_line_endings": true,
"highlight_line": true,
"highlight_modified_tabs": true,
"show_full_path": true,
"preview_on_click": false,
"folder_exclude_patterns": [".git", "node_modules", "__pycache__"],
"file_exclude_patterns": ["*.pyc", "*.class", "*.o", "*.so", "*.dll"],
"binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"]
}
Key Bindings Configuration
// Default (Windows).sublime-keymap - Custom Key Bindings
[
{ "keys": ["ctrl+shift+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
{ "keys": ["ctrl+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["ctrl+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
{ "keys": ["ctrl+`"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },
{ "keys": ["ctrl+shift+`"], "command": "new_window" },
{ "keys": ["ctrl+k", "ctrl+b"], "command": "toggle_side_bar" },
{ "keys": ["ctrl+k", "ctrl+m"], "command": "toggle_minimap" },
{ "keys": ["alt+shift+1"], "command": "set_layout", "args": {"cols": [0.0, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1]]} },
{ "keys": ["alt+shift+2"], "command": "set_layout", "args": {"cols": [0.0, 0.5, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]} },
{ "keys": ["alt+shift+3"], "command": "set_layout", "args": {"cols": [0.0, 0.33, 0.66, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1]]} },
{ "keys": ["ctrl+shift+t"], "command": "reopen_last_file" },
{ "keys": ["ctrl+shift+a"], "command": "expand_selection", "args": {"to": "tag"} },
{ "keys": ["ctrl+shift+j"], "command": "expand_selection", "args": {"to": "indentation"} },
{ "keys": ["ctrl+shift+space"], "command": "expand_selection", "args": {"to": "scope"} },
{ "keys": ["ctrl+alt+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+alt+down"], "command": "select_lines", "args": {"forward": true} }
]
Project Configuration Example
// project_name.sublime-project - Project Settings
{
"folders": [
{
"name": "Source",
"path": "./src",
"folder_exclude_patterns": ["__pycache__", "*.egg-info"],
"file_exclude_patterns": ["*.pyc", "*.pyo"]
},
{
"name": "Tests",
"path": "./tests"
},
{
"name": "Docs",
"path": "./docs"
}
],
"settings": {
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
"rulers": [79, 99],
"word_wrap": true,
"wrap_width": 79
},
"build_systems": [
{
"name": "Python",
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"working_dir": "${project_path}"
},
{
"name": "Node.js",
"cmd": ["node", "$file"],
"selector": "source.js",
"working_dir": "${project_path}"
}
]
}
Snippet Example
<!-- python_class.sublime-snippet - Python Class Template -->
<snippet>
<content><![CDATA[
class ${1:ClassName}:
"""${2:Class description}"""
def __init__(self${3:, param}):
"""Initialize ${1:ClassName}.
Args:
${3:param}: ${4:Parameter description}
"""
${5:pass}
def ${6:method_name}(self${7:, param}):
"""${8:Method description}.
Args:
${7:param}: ${9:Parameter description}
Returns:
${10:Return description}
"""
${11:pass}
]]></content>
<tabTrigger>class</tabTrigger>
<scope>source.python</scope>
<description>Python Class Template</description>
</snippet>
Macro Example
// Default.sublime-macro - Comment Toggle Macro
[
{
"command": "move_to",
"args": {"to": "bol", "extend": false}
},
{
"command": "move_to",
"args": {"to": "bol", "extend": true}
},
{
"command": "toggle_comment"
},
{
"command": "move",
"args": {"by": "lines", "forward": true}
}
]
Package Control Configuration
// Package Control.sublime-settings - Package Management Settings
{
"bootstrapped": true,
"in_process_packages": [],
"installed_packages": [
"A File Icon",
"All Autocomplete",
"Anaconda",
"AutoFileName",
"BracketHighlighter",
"Color Highlight",
"DocBlockr",
"Emmet",
"GitGutter",
"HTML-CSS-JS Prettify",
"Markdown Preview",
"Package Control",
"SideBarEnhancements",
"SublimeLinter",
"SublimeLinter-eslint",
"SublimeLinter-flake8",
"Theme - Spacegray"
],
"repositories": []
}
Syntax Definition Example
# CustomLanguage.sublime-syntax - Custom Language Syntax
%YAML 1.2
---
name: Custom Language
file_extensions: [cust]
scope: source.custom
contexts:
main:
- match: '#.*$'
scope: comment.line.number-sign.custom
- match: '"'
scope: punctuation.definition.string.begin.custom
push: double_quoted_string
- match: '\b(function|if|else|while|for)\b'
scope: keyword.control.custom
- match: '\b\d+\b'
scope: constant.numeric.custom
- match: '\b[a-zA-Z_][a-zA-Z0-9_]*\b'
scope: variable.other.custom
double_quoted_string:
- meta_scope: string.quoted.double.custom
- match: '\\.'
scope: constant.character.escape.custom
- match: '"'
scope: punctuation.definition.string.end.custom
pop: true