Commands are the basic method for interacting with Sublime Text. Key bindings, menu items, toolbar buttons and macros all work through the command system. If you are editing one of those files, this reference will come in handy.
Each command may take one or more parameters, which may be enclosed in quotes. For example, the command to insert the string Hello World!, followed by a newline, is:
| move |
move mode amount [extend]
| mode | One of characters, words, wordends, wordboundaries, lines or pages |
| amount | The number of mode elements to move the cursor by |
| extend | If this has the literal value "extend", the selection will be extended in the direction of movement |
Moves each cursor, by the given mode, amount number of times.
|
| moveTo |
moveTo position
| position | One of bol, eol, bof, eof |
| extend | If this has the literal value "extend", the selection will be extended in the direction of movement |
Moves each cursor directly to the indicated position
|
| expandSelectionTo |
expandSelectionTo feature
| feature | One of line, word, scope, brackets |
|
| expandSelectionToParagraph | Expands each selection region to the enclosing paragraph |
| selectAll | Selects the entire buffer |
| invertSelection | Selects the non-selected portion of the buffer, and unselects the currently selected portion |
| singleSelection | Remove all selection regions bar the first |
| splitSelection | Replace each non-empty selection region with two empty regions, one for each end |
| splitSelectionIntoLines | Split each selection region into subsets, one for each line |
| insertCharacters | Insert the characters given in the first parameter |
| insertAndDecodeCharacters | Insert the characters given in the first parameter, and apply automatic indentation |
| leftDeleteCharacterss | Erase the contents of each non-empty region, and the character to the left of every empty region |
| rightDeleteCharacters | Erase the contents of each non-empty region, and the character to the right of every empty region |
| copy | Copies the current selection to the clipboard |
| cut | Cuts the current selection to the clipboard |
| paste | Replaces the current selection with the contents of the clipboard |
| undo | Undoes the last action |
| redo | Redoes the last action |
| repeat | Repeats the last action |
| redoOrRepeat | Redoes the last action if the redo stack isn't empty, otherwise repeats the last action |
| join | Joins the following line to the current line, replacing all in between whitespace with a single space |
| indent | Indents the lines currently intersecting the selection |
| unindent | Unindents the lines currently intersecting the selection |
| scroll |
scroll amount
| amount | The number of lines to scroll |
Scroll the view by the given number of lines
|
| displayName | Show the name of the text under the cursor in the status bar |
| autoComplete | Complete the current word based on other words in the buffer |
| toggleComment | Adds or removes comments around each selection region. If "block" is supplied as a parameter, block comments will be preferred |
| swapCase | Inverts the case of each selected character |
| upperCase | Makes each selected character upper case |
| lowerCase | Makes each selected character lower case |
| wrapLines |
wrapLines [column]
| column | The column to wrap the paragraph at |
Reformat the current paragraph, ensuring that no line is wider than the column width. If no width is given, it's inferred from the current ruler, or defaults to 70 characters if there is no ruler
|
| sortLines |
sortLines [caseSensitive] [reverse] [removeDuplicates]
| caseSensitive | If present, the comparison will regard upper case characters as coming before lower case ones |
| reverse | If present, the order will be reversed |
| removeDuplicates | If present, duplicated strings will be eliminated |
Sorts all lines intersecting a selection region
|
| sortSelection |
sortSelection [caseSensitive] [reverse] [removeDuplicates]
| caseSensitive | If present, the comparison will regard upper case characters as coming before lower case ones |
| reverse | If present, the order will be reversed |
| removeDuplicates | If present, duplicated strings will be eliminated |
Sorts contents of each selection region with respect to each other
|
| permuteLines |
permuteLines method
| method | The permutation used, one of reverse, shuffle or unique |
Rearranges all lines intersecting a selection region using the given method
|
| permuteSelection |
permuteSelection method
| method | The permutation used, one of reverse, shuffle or unique |
Rearranged the contents of each selection region with respect to each other, using the given method
|
| findNext | Finds the next occurrence of the text in the find buffer |
| findPrev | Finds the previous occurrence of the text in the find buffer |
| findFindUnder | Places the current selection (or word if the selection is empty) in the find buffer, and finds the next occurrence |
| findNext | Places the current selection (or word if the selection is empty) in the find buffer, and finds the previous occurrence |
| findAllUnder | Places the current selection (or word if the selection is empty) in the find buffer, and finds all occurrences |
| incrementalFind | Open the incremental find panel, and set the find direction to forward |
| reverseIncrementalFind | Open the incremental find panel, and set the find direction to reverse |
| new | Creates a new buffer |
| open | Opens the file(s) given as parameters, or prompts the user for a file name if none are given |
| openInCurrentTab | Opens the file(s) given as parameters, or prompts the user for a file name if none are given. The view in the current tab is first closed, and replaced with the newly opened vie |
| openWithEncoding |
openWithEncoding encoding [filename]
| encoding | One of Undefined, Windows-1252, UTF-16 BE, UTF-16 LE, UTF-8 |
Opens the given file with the encoding, prompting the user for a file name if none is given
|
| switchFile |
switchFile extensions
| extensions | A space separated list of extensions to search through |
Opens a file with the same base name, but different extension that the current file. Used to toggle between .h and .c files, for example.
|
| clone | Creates a new view into the current buffer |
| close | Closes the current view |
| closeAll | Closes all views |
| save | Saves the current buffer, prompting for a file name if it doesn't have one yet |
| saveAll | Saves all buffers, prompting for a file name for any that don't yet have one |
| saveAs |
saveAs [encoding]
| encoding | One of Undefined, Windows-1252, UTF-16 BE, UTF-16 LE, UTF-8 |
Save the current buffer, prompting for a new name
|
| nextView | Selects the next tab |
| prevView | Selects the previous tab |
| copyPath | Copies the file name of the current buffer to the clipboard |
| newWindow | Opens a new window |
| closeWindow | Closes the current window |
| exit | Closes all windows |
| toggleFullScreen | Toggle the current window between full screen and windowed mode |
| moveToGroup |
moveToGroup group
Moves the current view to the given group
|
| focusGroup |
focusGroup group
Activates the given group
|
| focusView |
focusView view
| view | 0 based view index within the current group |
Activates the given view within the active group
|
| layoutSingle | Sets the layout to a single group |
| layoutDoubleHoriz | Sets the layout to two groups, one above the other |
| layoutDoubleVert | Sets the layout to two groups, side by side |
| layoutTriple | Sets the layout to three groups |
| layoutTripleVert | Sets the layout to three groups, side by side |
| layoutQuad | Sets the layout to four groups, in a grid |
| layoutQuadVert | Sets the layout to four groups, side by side |
| showPanel |
showPanel panel
| panel | The panel to show, one of find, incfind, replace, output, console or goto |
Show the given panel
|
| hidePanel | Hide the currently displayed panel |
| openInBrowser | Opens a web browser displaying the current file |
| terminate | Terminates the process currently running in the output window, if any |
| browseUrl |
browseUrl url
Opens the given URL in the system browser
|
| browseDir |
browseDir path
Opens the system file browser at the given path
|
| sendEmail |
sendEmail email
| email | The email address to send to |
Opens the default mail client to compose a message to the given email address
|