Sublime Text

From HaFrWiki
Jump to: navigation, search

Sublime Text is a sophisticated text editor for code, markup and prose [1][2]. You'll love the slick user interface, extraordinary features and amazing performance. First of all Sublime Text is multi-platform, so available for OS X, Windows and Linux.

Keyboard shortcuts

One very important shortcut for OSX is the one is the ⌘ + ⇧ + . which shows the normal hidden files in a directory (i.e. .bashrc) [3].

The keyboard shortcuts for OSX are base on the Websites:

Keypress Command
⌘ + X Cut line
⌘ + ↩ Insert line after
⌘ + ⇧ + ↩ Insert line before
⌘ + ⌃ + ↑ Move line / selection up
⌘ + ⌃ + ↓ Move line/selection down
⌘ + D Select word - Repeat to select next occurrence
⌘ + L Select line - Repeat to select next lines
⌃ + ⌘ + G Select all occurrence of the line above
⌃ + ⇧ + ↑ Extra cursor on the line above
⌃ + ⇧ + ↓ Extra cursor on the line below
⌃ + M Jump to closing parentheses Repeat to jump to opening parentheses
⌃ + ⇧ + M Select all contents of the current parentheses
⌃ + A
⌘ + Left
Move to beginning of line
⌃ + E
⌘ + Right
Move to end of line
⌘ + K, ⌘ + K Delete from cursor to end of line
⌘ + K + ⌫ Delete from cursor to start of line
⌘ + ] Indent current (selected) line(s)
⌘ + [ Un-Indent current (selected) line(s)
⌘ + ⇧ + D Duplicate line(s)
⌘ + J Join line below to the end of the current line
⌘ + / Comment/un-comment current line
⌘ + ⌥ + / Block comment current selection
⌘ + Y Redo, or repeat last keyboard shortcut command
⌘ + ⇧ + V Paste and indent correctly
⌃ + Space Select next auto-complete suggestion
⌃ + U Soft undo; jumps to your last change before undoing change when repeated
⌃ + ⇧ + Up Column selection up
⌃ + ⇧ + Down Column selection down
⌃ + ⇧ + W Wrap Selection in html tag
⌃ + ⇧ + K Delete current line of cursor
Navigation / Goto anywhere
Keypress Command
⌃ + G Goto line in current file, overlay (:)
⌘ + P
⌘ + T
Quick-open files by name
⌘ + ⇧ + R Goto symbol / function / method, overlay (@)
F12 Goto definition
⌃ + - Jump back, go to previous location
⌃ + ⇧ + - Jump forward, go to next location.


Keypress Command
⌘ + ⇧ + P Command Palette
⌃ + ` Python Console
⌃ + ⌘ + F Toggle fullscreen mode
⌃ + ⇧ + ⌘ + F Toggle distraction free mode
⌘ + K, ⌘ + B Toggle side bar
⌃ + ⇧ + P Show scope in status bar


Keypress Command
⌘ + ⇧ + T Open last closed tab
⌘ + [NUM] Jump to tab in current group where num is 1-9
⌘ + 0 Jump to 10th tab in current group
⌘ + ⇧ + [ Cycle left through tabs
⌘ + ⇧ + ] Cycle right through tabs
^ + Tab Cycle up through recent tabs
^ + ⇧ + Tab Cycle down through recent tabs


Keypress Command
⌘ + ⇧ + . Shows all files in directory
Split Window
Keypress Command
⌘ + ⌥ + 1 Revert view to single column
⌘ + ⌥ + 2 Split view into two columns
⌘ + ⌥ + 3 Split view into three columns
⌘ + ⌥ + 4 Split view into four columns
⌘ + ⌥ + 5 Set view to grid (4 groups)
⌃ + [NUM] Jump to group where num is 1-4
⌃ + ⇧ + [NUM] Move file to specified group where num is 1-4


Keypress Command
⌘ + F2 Toggle bookmark
F2 Next bookmark
⇧ + F2 Previous bookmark
⇧ + ⌘ + F2 Clear bookmarks


Text manipulation
Keypress Command
⌘ + K, ⌘ + U Transform to Uppercase
⌘ + K, ⌘ + L Transform to Lowercase
⌘ + ⌃ + up Clip text upwards, exchange 2-lines
⌘ + ⌃ + down Clip text downwards, exchange 2-lines


Find / Replace
Keypress Command
⌘ + F Find in file
⌘ + ⌥ + F Replace in file
⌘ + ⇧ + F Find in files


Command Palette

The Command Palette holds infrequently used functionality, like sorting, changing the syntax and changing the indentation settings. With just a few keystrokes, you can search for what you want, without ever having to navigate through the menus or remember obscure key bindings.
Show the Command Palette with ⌘⇧P.

  • Snippet to insert a code snippet.
  • Rename to rename a file
  • Package Control to see or insert Packages.
Goto Anything

Use Goto Anything to open files with only a few keystrokes, and instantly jump to symbols, lines or words.
Triggered with ⌘P, it is possible to:

  • Type part of a file name to open it.
  • Type @ to jump to symbols,
  • Type # to search within the file,
  • Type : to go to a line number.

These shortcuts can be combined, so tp@rf may take you to a function read_file within a file
Similarly, tp:100 would take you to line 100 of the same file.

Split Editing

Get the most out of your wide screen monitor with split editing support. Edit files side by side, or edit two locations in the one file. You can edit with as many rows and columns as you wish.
Take advantage of multiple monitors by editing with multiple windows, and using multiple splits in each window.

  • Take a look at the ViewLayout menu for split editing options.
  • To open multiple views into the one file, use the FileNew View into File menu item.
Multiple Selections

Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.

  • Try pressing ⇧⌘L to split the selection into lines
  • ⌘D to select the next occurrence of the selected word.
  • To make multiple selections with the mouse, take a look at the Column Selection documentation.
Distraction Free Mode

When you need to focus, Distraction Free Mode is there to help you out. Distraction Free Mode is full screen, chrome free editing, with nothing but your text in the center of the screen.
You can incrementally show elements of the UI, such as tabs and the find panel, as you need them.

  • You can enter Distraction Free Mode using the ViewEnter Distraction Free Mode menu.
Instant Project Switch

Projects in Sublime Text capture the full contents of the workspace, including modified and unsaved files. You can switch between projects in a manner similar to Goto Anything, and the switch is instant, with no save prompts - all your modifications will be restored next time the project is opened.

Goto Definitions

Using information from syntax definitions, Sublime Text automatically generates a project-wide index of every class, method and function. This index powers Goto Definition, which is exposed in three different ways:

  • A popup is displayed when hovering over a symbol
  • Pressing F12 when the caret is on a symbol
  • The Goto Symbol in Project functionality

Symbol indexing can be customized on a per-syntax basis via configuration files, allowing users to tailor the feature to their needs.


Completion are a powerful engine supplied in Sublime [4]. But can also be very annoying.


Sublime Text includes a few methods to save typing and time by finishing words or inserting boilerplate. Completions include the following sources:

Completion source Location 1 Extension
Words from the current file Edited File Edited File
Context-aware suggestions
Completion files Sublime Text 3/Packages/PHP sublime-completions
Snippet files Sublime Text 3/Packages/PHP/Snippets 2 sublime-snippet
Plugins ToDo ToDo
  • 1. Location : The location is always relative to the ~/Library/Application Support directory
  • 2. XXX : The name of the programming language i.e. PHP as shown here


By default, Sublime Text will automatically show the completions popup when a user is editing source code or markup, but not within prose in comments, strings or markups. Pressing the Esc key will hide the completions popup. To manually show the completions popup, press Ctrl+Space. If no completions are available, the message No available completions will be displayed in the status bar.

Context-Aware Suggestions

The completion engine in Sublime Text uses background processes to scan all of the files in a project to build a completion index. This index is used to provide suggested completions to the user, based on patterns in existing code.


There exists a number of ways in which the engine can be augmented with new completions:

  • Completion Files
  • Snippets
  • Plugins

Completion Files

The most basic form of adding completions to Sublime Text is by creating a .sublime-completions file.
Completions files use the JSON format, and contain an object with the keys "scope" and "completions".
The Scope key’s value is a string containing a selector of the syntax the completions apply to.
The completions value is an array of completions.
Each entry in the array represents a single completion, and may be a string or an object.

trigger string Required The text the user has to enter to match the completion.
contents string Required The content that will be inserted into the file.
Supports snippets and variables.
annotation string 4.0 The annotation to display before the completion.
kind string 4.0 3-element array of strings (ambiguous, function, keyword, markup, namespace, navigation, snippet, type, variable).
details string 4.0 A single line description of the completion.
    "scope": "source.python",
    "completions": [
            "trigger": "def",
            "contents": "def",
            "kind": "keyword"
            "trigger": "fun",
            "annotation": "basic function",
            "contents": "def ${1:name}($2):\n    $0\n",
            "kind": "snippet",
            "details": "A simple, non-<code>async</code> function definition"


Snippets are typically used for boilerplate-type content that isn’t easily authored using the .sublime-completions format due to spanning multiple lines.
Snippets are XML files with the extension .sublime-snippet.
They have a top-level tag <snippet>, containing the following tags:

  • scope : The selector of the syntax the snippet should be enabled for
  • tabTrigger : The text used to match the snippet in the completions popup
  • contents : The text to insert into the document when the snippet it applied. Supports fields and variables.
    Typically the contents of this tag are wrapped in <![CDATA[ and ]]> so that the contents do not need to be XML-escaped.
  • description : An optional description of the snippet, which is shown in the Command Palette
    <content><![CDATA[def ${1:name}($2):
    <description>function, non-async</description>


The most powerful tool for adding completions are Python plugins.
Writing a plugin to provide completions involves implementing the method on_query_completions() on a class that extends EventListener or ViewEventListener.
See the documentation on

Git Integration

Sublime Text's Git integration includes the following components:

  • Side Bar
  • Status Bar
  • Diff Markers
  • Sublime Merge Integration
  • Settings

For the full description go to:

Side Bar

Files and folders displayed in the side bar will include a status badge along the right-hand edge, when modified. This includes files and folder in the Folders section of the side bar, along with files in the Open Files section. Ignored files and folders are de-emphasized in the side bar by reducing the opacity of the name.

When the mouse pauses over a status badge, a tool tip will be displayed indicating the status of the file, or in the case of a folder, the status of the contained files and folders.

Status Badge Key

The following table indicates the meaning of each badge. Please note that the color of the badges will be slightly different as they adapt to the closest hue in the active color scheme.

  • Untracked, white circle
  • 🔵 Modified, blue circle
  • 🔴 Missing, red circle
  • Staged Addition, Green heavy wedge tailed rightwards arrow.
  • Staged Modification
  • Staged Deletion
  • Unmerged, symbol not yet found.



GitSavvy provides integration between Sublime Text 3 and Git.

If you're a new user and you find yourself asking, "Can GitSavvy do X?", there are two places to look.

  1. Open your command palette and type `GitSavvy: help`. This will take you to the offline wiki-style documentation.
  2. You can also check for configurability options by opening `Preferences > Package Settings > GitSavvy > Settings - Default` in the ST3 menu.
    Any optional or configurable behavior will be documented here, along with the default values.

If you need help along the way, there's usually someone around in our Gitter channel:

Finally, if at any time you encounter a bug, or if you wish that GitSavvy included some missing functionality, please open an issue:

On youtube:


The spellings-package is based on Hunspell [5][6].

Adding Language

To add a new language to sublime text 3

  • Download the language file from the appropriate OpenOffice extension [7].
  • Rename the "some.oxt" file to ""
  • Unzip the file
  • Look for two files:
    • "lang.aff"
    • "lang.dic
  • For example es_ES.aff and es_ES.dic
  • Open the "lang.aff" to check the encoding used. Such the line: SET ISO-8859-1
  • Convert that file to UTF-8 from the used encoding
  • Convert "lang.dic" to UTF-8 from the used encoding.
  • Change SET ISO-8859-1 to SET UTF-8
  • In ST3, click on Preferences -> Browse Packages
  • Create a new folder, for example Language - Spanish
  • Move lang.dic and lang.aff to that folder
  • Activate the dictionary in ST3 (View -> Dictionary -> Language - Spanish -> es_ES)
  • Press F6 to enable spell check

adapted from the github repo for SublimeText/Dictionaries

Sublime Preferences

File Indexing

Some of the core features in Sublime Text 3 are Goto Definition and Goto Symbol in Project [8]. Both of these work by indexing the files in the current project to determine where each symbol is defined.
To see when files are being indexed, you can enter sublime.log_indexing(True) in Sublime Text's console. This will trigger Sublime Text to start logging relevant information whenever it indexes files.

In the latest version 4107 this in the background working mechanism has been extended causing the complete editor to become terrible slow.
So what to do?

  • First of all, disable file indexing by setting the command below into the Preferences.sublime-setting (user of course, not the index-itself).
    • index_files: false.
  • File indexing works by applying syntax highlighting rules to each file, and then extracting everything that looks like a symbol.
    The syntax highlighting rules are regex based, and some combinations of rules and files can cause the parsing to take a long time.
    See the log-file what's going on, and then consider adding the files to the index_exclude_patterns setting.
    Also look for binary_file_patterns and file_exclude_patterns [9].
  • Various events can cause the index itself to become corrupted, and when this happens, Sublime Text will do the indexing work, but be unable to write the results to disk, so it'll start again in the near future.
    The next build of Sublime Text will handle this situation more gracefully, but in the mean time you can check this for yourself: if the index is corrupted, there will be a log message in the console (accessible from the View/Show Console menu), which indicates which directory needs to be deleted to reset the index.

See also


  • Git, Version Control System.
  • iVim, iVim For iOS. An alternative for Sublime Text on iOS (since Sublime is not on iOS).



  1. SublimeText, A programmers editor the way it should be.
  2. Sublime trademark of © Sublime HQ Pty Ltd, Woollahra, Sydney.
  3. Stack-Exchange, Show hidden files in the open file dialog on OSX.
  4. Sublime Text Docs, Source of the documentation on Completions.
  5. Hunspell, About.
  6., Documentation man-page Hunspell.
  7. Spell Checking.
  8. SublimeText Blog, Articles File-Indexing.
  9. StackOverflow, Excluding a folder from indexing Sublime Text