title |
---|
Commands Overview |
::: tip Note This list of commands is a work in progress. :::
Some commands take paths as parameters. Among these, some support snippet-like
syntax, while others don't. A command of the first kind would take a parameter
like ${packages}/SomeDir/SomeFile.ext
whereas a command of the second kind
would take a parameter like Packages/SomeDir/SomeFile.ext
.
Generally, newer commands support the snippet-like syntax.
Commands expect UNIX-style paths if not otherwise noted, including on
Windows (for example, /c/Program Files/Sublime Text 3/sublime_plugin.py
).
Often, relative paths in arguments to commands are assumed to start at the .
Inserts a string at the end of the view.
- characters (String): String to be inserted.
- force (Bool):
- scroll_to_end (Bool):
Add selected text to an internal buffer "kill ring" (paste it with yank).
Opens the auto complete list.
Runs a build system.
- variant (String): Optional. The name of the variant to be run.
Chains multiple commands to execute together. Below are the parameters accepted by the this command.
- commands [[String, ArgsMapping]] or [[{"command": String, "args": ArgsMapping]]: The chain of commands that will be executed.
The chain
command can be implemented using the below syntax:
{
"command": "chain",
"args": {
"commands" : [
["command1", {"arg1": "value1", "arg2": "value2"}],
["command2", {"arg1": "value1", "arg2": "value2"}],
["command3", {"arg1": "value1", "arg2": "value2"}],
]
}
}
The list of commands can also be replaced with an object containing the command and arguements if required demonstrated as below:
{
"command": "chain",
"args": {
"commands" : [
{"command": "command1", "args": {"arg1": "value1", "arg2": "value2"}}
{"command": "command2", "args": {"arg1": "value1", "arg2": "value2"}}
]
}
}
If no name argument, or the name "bookmarks" is specified, it removes all bookmarks set in the current file, but not the marks. If the name "mark" is specified as an argument, it removes all marks set in the current file, but not the bookmarks.
- name (String): e.g.
"mark"
,"bookmarks"
.
Breaks out of the active snippet field cycle.
Deletes records of recently accessed files and folders.
Deletes records of recently accessed projects.
Clones the current view into the same tab group, both sharing the same buffer. That means you can drag one tab to another group and every update to one view will be visible in the other one too.
Closes the active view and, under certain circumsances, the whole application.
Removes all folders from the current project.
Closes the current project.
Surrounds the current inner text with the appropiate tags.
Closes the active window.
Closes the active view.
Inserts into the buffer the item that's currently selected in the auto complete list.
Shows the context menu.
Sends the selected text to to the system clipboard.
Removes the selected text and sends it to the system clipboard. Put differently, it cuts.
Decreases the font size.
Deletes the text that select_to_mark
would select to an internal buffer
"kill ring" (paste it with yank).
Guesses the indentation from the current file.
Duplicates the current line.
Runs an external process asynchronously. On Windows, GUIs are supressed.
exec
is the default command used by build systems, thus it provides
similar functionality. However, a few options in build systems are taken
care of by Sublime Text internally so they list below only contains
parameters accepted by this command.
- cmd [(String)]
- shell_cmd (String): Shell command to use. If given overrides
cmd
and ignoresshell
. - file_regex (String)
- line_regex (String)
- working_dir (String)
- encoding (String)
- env [{String: String}]
- quiet (Bool): If
True
no runtime information is printed if the command fails or has a non-zero exit code. - kill (Bool): If
True
will simply terminate the current build process. This is invoked via Build: Cancel command from the Command Palette. - update_phantoms_only (Bool)
- hide_phantoms_only (Bool)
- word_wrap (Bool): Whether to word-wrap the output in the build panel
- syntax (String): Syntax file used to colour output.
- path (String)
- shell (Bool)
::: info See Also
exec
Target options
: Detailed documentation on all parameters of the exec
command.
:::
Exits the whole application with all open windows.
Extends the selection up to predefined limits.
- to (Enum): Values: bol, hardbol, eol, hardeol, bof, eof, brackets, line, tag, scope, indentation.
Converts tabs to spaces.
- set_translate_tabs (Bool)
Finds all occurrences of the current selection or the current word.
Finds the next occurrence of the current search term.
Finds the previous occurrence of the current search term.
Adds a new selection based on the current selection or expands the selection to the current word while removing the current selection.
Adds a new selection based on the current selection or expands the selection to the current word.
Finds the previous occurrence of the current selection or the current word.
Finds the next occurrence of the current selection or the current word.
Gives focus to the top-most file in the specified group.
- group (Int): The group index to focus. This is determined by the order
of
cells
items from the current layout (seeWindow.set_layout
).
Scans the whole file and folds everything with an indentation level of
level
or higher. This does not unfold already folded regions if you first
fold by level 2 and then by 3, for example. Sections with cursors are not
folded.
- level (Int): The level of indentation that should be folded.
0
is equivalent to running #### unfold_all.
Folds all tag attributes in XML files, only leaving the tag's name and the closing bracket visible.
Folds the current selection and displays …
instead. Unfold arrows are
added to the lines where a region has been folded.
Hides the auto complete list.
Hides the active overlay. Show the overlay using the show_overlay command.
Hides the active panel.
- cancel (Bool): Notifies the panel to restore the selection to what it was when the panel was opened. (Only incremental find panel.)
Increases the font size.
Increments indentation of selection.
Inserts the best completion that can be inferred from the current context.
- default (String): String to insert failing a best completion.
Inserts a snippet from a string or .sublime-snippet file.
- contents (String): Snippet as a string to be inserted. Remember that
backslashes
\
have to be escaped, like in every other JSON string. - name (String): Relative path to the .sublime-snippet file to be inserted.
::: info See Also Snippets
Documentation on snippets and their variable features. :::
Inserts a string.
- characters (String): String to be inserted.
Joins the current line with the next one.
Deletes the character right before the caret.
Makes the selection lower case.
Moves the current file to the specified group.
- group (Int): The group index to focus. See #### focus_group command.
Advances the caret to predefined locations.
- to (Enum): Values: bol, eol, bof, eof, brackets.
- extend (Bool): Whether to extend the selection. Defaults to
false
.
Advances the caret by predefined units.
- by (Enum): Values: characters, words, word_ends, subwords, subword_ends, lines, pages, stops.
- forward (Bool): Whether to advance or reverse in the buffer.
- word_begin (Bool)
- empty_line (Bool)
- punct_begin (Bool)
- separators (Bool)
- extend (Bool): Whether to extend the selection. Defaults to
false
.
Creates a new buffer and inserts a build system template.
Creates a new buffer and inserts a plugin template (a text command).
Creates a new buffer and inserts a snippet template.
Opens a new window.
Select the next bookmarked region.
Advances the caret to the text snippet field in the current snippet field cycle.
Advance to the next misspelling
Advance to the next captured result.
Switches to the most recently active view.
Switches to the next view.
Opens the specified directory with the default file manager.
- dir (String): The directory to open.
Opens the syntax-specific user settings file for the current syntax.
Opens the specified file. Will dynamically open resource files from sublime-package archives as read-only if the specified override file does not exist.
-
file (String): Absolute or relative path to the file to be opened. Relative paths will originate from the recently
Expands snippet-like variables, such as
$platform
and$packages
. -
contents (String): This string will be written to the new buffer if the file does not exist. accessed directory (e.g. the directory of the currently opened file).
Opens a recently closed file.
- index (Int)
Opens a recently closed folder.
- index (Int)
Opens a recently closed project.
- index (Int)
Opens the specified url with the default browser.
- url (String)
Inserts the clipboard contents after the caret and indents contextually.
Inserts the clipboard contents after the caret.
- clipboard (String): May be selection. XXX what other values are allowed?
XXX
- operation (Enum): reverse, unique, shuffle ...?
XXX
- operation (Enum): reverse, unique, shuffle ...?
Select the previous bookmarked region.
Moves the caret to the previous snippet field in the current snippet field cycle.
Move to the previous misspelling.
Move to the previous captured result.
Switches to the view that was active before the most recently active view.
Switches to the previous view.
Prompts for a folder to add to the current project.
Prompts for a project file to open as a project.
Prompts for a new file name and saves the active file.
Opens a popup with recently accessed projects where you can fuzzy-search.
Performs the latest action again.
Reapplies the latest undone action.
Reloads all folders in the current project and updates the side bar.
Corrects indentation of the selection with regular expressions set in the syntax's preferences. The base indentation will be that of the line before the first selected line. Sometimes does not work as expected.
Reopens the last closed file.
Reopens the current file.
- encoding (String): The file encoding the file should be reopened with.
XXX
Resets the font size to the default
Note: This essentially removes the entry from your User settings, there might be other places where this has been "changed".
Undoes all unsaved changes to the file.
Deletes the character right after the caret.
Runs a .sublime-macro file.
- file (String): Relative path to the macro file.
Runs the macro stored in the macro buffer.
Saves all open files.
Prompts for a file path to save the macro in the macro buffer to.
Prompts for a new file name and saves the current project.
Saves the active file.
- encoding (String): The file encoding to save as.
Scrolls lines in the view.
amount [Float]: Positive values scroll lines down (view up) and negative values scroll lines up (view down).
Selects all bookmarked regions.
Select the view's content.
Selects a bookmarked region in the current file.
- index (Int)
Focuses a certain tab in the current group.
- index (Int): The tab index to focus.
Adds a line to the current selection.
- forward (Bool): Whether to add the next or previous line. Defaults to
true
.
Selects the text between the current position of each one of the current carets and the marked position. Each caret is matched with each mark in order of occurrence, and is moved to the beginning of its selection.
If any number of selections overlap, they are joined and, of all the carets corresponding to each one of the joined selections, only the one occurring first in the file is preserved.
If the number of current carets is less or equal to the number of marks, the remaining marks in order are ignored. Conversely, if currently there are more carets than marks, the first relevant selections are produced. Of all extra marks, those contained in the selections are removed, and the rest of them are left where they are, without triggering a selection from their position.
Changes the current build system.
- file (String): Path to the build system. If empty, Sublime Text tries to automatically find an appropriate build systems from specified selectors.
- index (Int): Used in the Tools | Build System menu but otherwise probably not useful.
Changes the group layout of the current window. This command uses the same
pattern as Window.set_layout
, see there for a list and
explanation of parameters.
Changes the line endings of the current file.
- type (Enum): windows, unix, cr
Marks the position of each caret in the current file. If any marks have already been set in that file, they are removed.
Set the value of a setting. This value is view-specific.
- setting (String): The name of the setting to changed.
- value (*): The value to set to.
I think you know what this does.
Scrolls the view to show the selected line in the middle of the view and adjusts the horizontal scrolling if necessary.
Shows the requested overlay. Use the #### hide_overlay command to hide it.
-
overlay (Enum): The type of overlay to show. Possible values:
- goto: Show the Goto Anything overlay.
- command_palette: Show the Command Palette.
-
show_files (Bool): If using the goto overlay, start by displaying files rather than an empty widget.
-
text (String): The initial contents to put in the overlay.
Shows a panel.
- panel (Enum): Values: incremental_find, find, replace, find_in_files, console or output.<panel_name>.
- pattern (String): The search string/pattern to add to the Find: field. (ST 4123+)
- replace_pattern (String): The replacement string to add to the Replace: field. (ST 4123+)
- reverse (Bool): Whether to search backwards in the buffer.
- toggle (Bool): Whether to hide the panel if it's already visible.
- highlight (Bool): Whether to highlight find results. (ST 4107+)
- in_selection (Bool): Whether to search within current selection only. (ST 4107+)
- preserve_case (Bool): Whether to preserve original casing when replacing text. (ST 4107+)
- regex (Bool): Whether to perform regular expression matching. (ST 4107+)
- use_gitignore (Bool): Whether to exclude git-ignored files from
find_in_files
search run. (ST4107+) - whole_word (Bool): Whether to search for whole words only. (ST4107+)
- wrap (Bool): Whether to continue search at the beginning of a document if end of file is reached. (ST4107+)
Shows the name for the caret's scope in the status bar.
Collapses multiple selections into a single selection.
Copies the current selection or word into the "find" field of the find panel.
Copies the current selection or word into the "replace" field of the find and replace panel.
Redoes each action stepping through granular edits.
Undoes each action stepping through granular edits.
Sorts lines.
- case_sensitive (Bool): Whether the sort should be case sensitive.
Sorts lines in selection.
- case_sensitive (Bool): Whether the sort should be case sensitive.
Splits the selection into multiple selections, one on each line.
Swaps the case of each character in the selection.
Swaps the current line with the line below.
Swaps the current line with the line above.
Marks all the current carets' positions, removes those carets, and sets new carets at the previously marked positions, if any.
Switches between two files with the same name and different extensions.
- extensions (String): Extensions (without leading dot) for which switching will be enabled.
Capitalizes the selection's first character and turns the rest into lower case.
Sets or unsets a bookmark for the active region(s). (Bookmarks can be
accessed via the regions API using "bookmarks"
as the key.)
Comments or uncomments the active lines, if available.
- block (Bool): Whether to insert a block comment.
Toggles distraction free mode on or off.
Toggles full screen mode on or off.
Shows or hides the minimap.
Toggles overwriting on or off.
Starts or stops the macro recorder.
Toggles whether all open files should be saved before starting the build.
Toggles the value of a boolean setting. This value is view-specific.
- setting (String): The name of the setting to be toggled.
Shows ot hides the open files in the sidebar.
Shows or hides the sidebar.
Shows or hides the status bar.
Shows or hides the tab bar.
Makes selections or characters swap places.
With selection: The contents of the selected regions are circulated. Without selection: Swaps adjacent characters and moves the caret forward by 1.
Undoes the latest action.
Converts spaces in indentation to tabs.
- set_translate_tabs (Bool)
Unfolds all folded regions.
Unfolds all folded regions in the selection or the current line if there is none.
Unindents selection.
Makes the selection upper case.
Wraps lines. By default, it wraps lines at the first ruler's column.
- width (Int): Specifies the column at which lines should be wrapped.
Paste text from the "kill ring" (added with add_to_kill_ring or delete_to_mark).
There are several ways to discover a command's name in order to use it as a key binding, in a macro, as a menu entry or in a plugin.
- Browsing the default key bindings at Preferences | Key Bindings - Default. If you know the key binding whose command you want to inspect, you can just search for it using the search panel. This, of course, also works in the opposite direction.
-
sublime.log_commands(True)
Running the above in the will tell Sublime Text to print the command's name in the console whenever a command is run. You can practically just enter this, do whatever is needed to run the command you want to inspect and then look at the console. It will also print the passed arguments so you can basically get all the information you need from it. When you are done, just run the function again with
False
as parameter. -
Inspecting
.sublime-menu
files. If your command is run by a menu item, browse the default menu file atPackages/Default/Main.sublime-menu
. You will find them quick enough once you take a look at it, or see the menu documentation.
- Similar to menus, you can do exactly the same with
.sublime-command
files. See completions for some documentation on completion files.