Commands

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:

insertCharacters "Hello World!\n"

Selection

move move mode amount [extend]
modeOne of characters, words, wordends, wordboundaries, lines, wholelines or pages
amountThe number of mode elements to move the cursor by
extendIf 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
positionOne of bol, hardbol, eol, hardeol, bof, eof
extendIf 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
featureOne of line, word, scope, brackets
expandSelectionToParagraphExpands each selection region to the enclosing paragraph
selectAllSelects the entire buffer
invertSelectionSelects the non-selected portion of the buffer, and unselects the currently selected portion
singleSelectionRemove all selection regions bar the first
splitSelectionReplace each non-empty selection region with two empty regions, one for each end
splitSelectionIntoLinesSplit each selection region into subsets, one for each line

Editing

insertCharactersInsert the characters given in the first parameter
insertAndDecodeCharactersInsert the characters given in the first parameter, and apply automatic indentation
leftDeleteCharactersErase the contents of each non-empty region, and the character to the left of every empty region. If spaces are being used for indentation, this will erase space characters until the next tab stop
leftDeleteCharactersSingleErase the contents of each non-empty region, and the character to the left of every empty region. This has no special behavior when translateTabsToSpaces is on
rightDeleteCharactersErase the contents of each non-empty region, and the character to the right of every empty region
deleteWord deleteWord direction
directionleft or right
Deletes a word to the left or right of each cursor
copyCopies the current selection to the clipboard
cutCuts the current selection to the clipboard
pasteReplaces the current selection with the contents of the clipboard
undoUndoes the last action
redoRedoes the last action
repeatRepeats the last action
redoOrRepeatRedoes the last action if the redo stack isn't empty, otherwise repeats the last action
joinJoins the following line to the current line, replacing all in between whitespace with a single space
indentIndents the lines currently intersecting the selection
unindentUnindents the lines currently intersecting the selection
scroll scroll amount
amountThe number of lines to scroll
Scroll the view by the given number of lines
displayNameShow the syntax name of the text under the cursor in the status bar
autoCompleteComplete the current word based on other words in the buffer
toggleCommentAdds or removes comments around each selection region. If "block" is supplied as a parameter, block comments will be preferred
swapCaseInverts the case of each selected character
upperCaseMakes each selected character upper case
lowerCaseMakes each selected character lower case
wrapLines wrapLines [column]
columnThe 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]
caseSensitiveIf present, the comparison will regard upper case characters as coming before lower case ones
reverseIf present, the order will be reversed
removeDuplicatesIf present, duplicated strings will be eliminated
Sorts all lines intersecting a selection region
sortSelection sortSelection [caseSensitive] [reverse] [removeDuplicates]
caseSensitiveIf present, the comparison will regard upper case characters as coming before lower case ones
reverseIf present, the order will be reversed
removeDuplicatesIf present, duplicated strings will be eliminated
Sorts contents of each selection region with respect to each other
permuteLines permuteLines method
methodThe permutation used, one of reverse, shuffle or unique
Rearranges all lines intersecting a selection region using the given method
permuteSelection permuteSelection method
methodThe permutation used, one of reverse, shuffle or unique
Rearranged the contents of each selection region with respect to each other, using the given method
swapLines swapLines direction
directionup or down
    Moves the selected line(s) in the given direction
</td>

Find

findNextFinds the next occurrence of the text in the find buffer
findPrevFinds the previous occurrence of the text in the find buffer
findUnderPlaces the current selection (or word if the selection is empty) in the find buffer, and finds the next occurrence
findUnderPrevPlaces the current selection (or word if the selection is empty) in the find buffer, and finds the previous occurrence
findAllUnderPlaces the current selection (or word if the selection is empty) in the find buffer, and finds all occurrences
incrementalFindOpen the incremental find panel, and set the find direction to forward
reverseIncrementalFindOpen the incremental find panel, and set the find direction to reverse

Bookmarks

toggleBookmarkAdds / Removes the current selection to the set of bookmarks
nextBookmarkSelect the next bookmark
prevBookmarkSelect the previous bookmark
allBookmarksSelects all bookmarks
clearBookmarksRemove all bookmarks
gotoBookmark gotoBookmark n
nWhich bookmark to select
Selects the nth bookmark from the top of the buffer

Spelling

nextMisspelledWordSelects the next misspelled word
prevMisspelledWordSelects the previous misspelled word

Macros

startRecordStarts recording a macro
stopRecordStops recording the current macro
toggleRecordStarts / Stops recording the current macro
runMacroRuns the last recorded macro
saveMacroSaves the last recorded macro to disk, prompting the user for a file name
runMacroFile runMacroFile filename
filenameThe macro file
Runs the commands in the given file, showing status information
runMacroFileSilently runMacroFileSilently filename
filenameThe macro file
Runs the commands in the given file, not showing any status information

View and Window Management

newCreates a new buffer
openOpens the file(s) given as parameters, or prompts the user for a file name if none are given
openInCurrentTabOpens 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]
encodingOne 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
extensionsA 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.
</td>

cloneCreates a new view into the current buffer
closeCloses the current view
closeAllCloses all views
saveSaves the current buffer, prompting for a file name if it doesn't have one yet
saveAllSaves all buffers, prompting for a file name for any that don't yet have one
saveAs saveAs [encoding]
encodingOne of Undefined, Windows-1252, UTF-16 BE, UTF-16 LE, UTF-8
Save the current buffer, prompting for a new name
nextViewSelects the next tab
prevViewSelects the previous tab
copyPathCopies the file name of the current buffer to the clipboard
newWindowOpens a new window
closeWindowCloses the current window
exitCloses all windows
toggleFullScreenToggle the current window between full screen and windowed mode
moveToGroup moveToGroup group
group0 based group index
Moves the current view to the given group
focusGroup focusGroup group
group0 based group index
Activates the given group
focusView focusView view
view0 based view index within the current group
Activates the given view within the active group
layoutSingleSets the layout to a single group
layoutDoubleHorizSets the layout to two groups, one above the other
layoutDoubleVertSets the layout to two groups, side by side
layoutTripleSets the layout to three groups
layoutTripleVertSets the layout to three groups, side by side
layoutQuadSets the layout to four groups, in a grid
layoutQuadVertSets the layout to four groups, side by side

Projects

newProjectCreates a new project
openProjectOpen the project given as a parameter, or displays an open dialog if none are given
closeProjectCloses the current project
editProjectOpens the project as a file for editing. The project will be reloaded after save.
scanProjectReloads the project, to pick up new files that should be included
openFileInProjectShows a quick panel to select a file in the project

Building

buildBuilds using the current build system, which may be set globally or per-project.

Build systems are defined by .sublime-build files. The format of these is simply to have two lines, one keyed on 'build' and the other 'lineNumberRegex'. These are then used to form an exec command, detailed below.

terminateCancels any currently executing process in the output panel
nextBuildErrorGoes to the source of the next build error
prevBuildErrorGoes to the source of the previous build error
exec exec lineNumberRegex command
lineNumberRegexThe regex that is used to identify build errors in the output. The first submatch should capture the file name, the second should capture the line number, and the third, if any, should capture the column number
commandThe system command to run
Runs the given system command, from the directory of the currently opened file, sending the output to the output panel. Within the command, the following substitutions are available:
$FileFull file name
$FileDirDirectory portion of the file name
$FileNameNon-directory portion of the file name
$FileExtFile extension
$BaseNameFilename with no directory and no extension
    Have a look within a .sublime-build file for an example of usage.
</td>

Snippets

insertSnippetInserts the snippet given as a parameter into the buffer
insertInlineSnippetAs above, but the contents of the snippet are given as a parameter to the command, rather than the name of a .sublime-snippet file
newSnippetCreates a new snippet, pre-filled out with the basic structure
nextFieldNavigates to the next field (tabstop) in the snippet
prevFieldNavigates to the previous field in the snippet
clearFieldsExits out of snippet mode

Other

showPanel showPanel panel
panelThe panel to show, one of find, incfind, replace, output, console or goto
Show the given panel
hidePanelHide the currently displayed panel
openInBrowserOpens a web browser displaying the current file
terminateTerminates the process currently running in the output window, if any
browseUrl browseUrl url
urlThe URL to open
Opens the given URL in the system browser
browseDir browseDir path
pathThe path to open
Opens the system file browser at the given path
sendEmail sendEmail email
emailThe email address to send to
    Opens the default mail client to compose a message to the given email address
</td>

wordCountShows a status message with the number of words in the buffer
rot13Applies a rot13 transformation to the selected text

Not Yet Documented

newPlugin
set
setApp
setUser
toggle
setFileType
setLineEnding
markSelection
prevInSelectionHistory
nextInSelectionHistory
clearSelectionHistory
mergeSelection
conflateSelection
times
sequence