sublime.View

ST2 Represents a view into a text buffer. Note that multiple views may refer to the same buffer, but they have their own unique selection and geometry.



ST3

Represents a view into a text buffer. Note that multiple views may refer to the same buffer, but they have their own unique selection and geometry.



add_regions ST2≠3

ST2 add_regions(key, [regions], scope, <icon>, <flags>) # => None

Add a set of regions to the view. If a set of regions already exists with the given key, they will be overwritten. The scope is used to source a color to draw the regions in, it should be the name of a scope, such as "comment" or "string". If the scope is empty, the regions won't be drawn.

The optional icon name, if given, will draw the named icons in the gutter next to each region. The icon will be tinted using the color associated with the scope. Valid icon names are dot, circle, bookmark and cross.

The optional flags parameter is a bitwise combination of:

  • sublime.DRAW_EMPTY. Draw empty regions with a vertical bar. By default, they aren't drawn at all.
  • sublime.HIDE_ON_MINIMAP. Don't show the regions on the minimap.
  • sublime.DRAW_EMPTY_AS_OVERWRITE. Draw empty regions with a horizontal bar instead of a vertical one.
  • sublime.DRAW_OUTLINED. Draw regions as an outline, rather than filled in.
  • sublime.PERSISTENT. Save the regions in the session.
  • sublime.HIDDEN. Don't draw the regions.



ST3 add_regions(key, [regions], <scope>, <icon>, <flags>) # => None

Add a set of regions to the view. If a set of regions already exists with the given key, they will be overwritten. The scope is used to source a color to draw the regions in, it should be the name of a scope, such as "comment" or "string". If the scope is empty, the regions won't be drawn.

The optional icon name, if given, will draw the named icons in the gutter next to each region. The icon will be tinted using the color associated with the scope. Valid icon names are dot, circle, bookmark and cross. The icon name may also be a full package relative path, such as Packages/Theme - Default/dot.png.

The optional flags parameter is a bitwise combination of:

  • sublime.DRAW_EMPTY: Draw empty regions with a vertical bar. By default, they aren't drawn at all.
  • sublime.HIDE_ON_MINIMAP: Don't show the regions on the minimap.
  • sublime.DRAW_EMPTY_AS_OVERWRITE: Draw empty regions with a horizontal bar instead of a vertical one.
  • sublime.DRAW_NO_FILL: Disable filling the regions, leaving only the outline.
  • sublime.DRAW_NO_OUTLINE: Disable drawing the outline of the regions.
  • sublime.DRAW_SOLID_UNDERLINE: Draw a solid underline below the regions.
  • sublime.DRAW_STIPPLED_UNDERLINE: Draw a stippled underline below the regions.
  • sublime.DRAW_SQUIGGLY_UNDERLINE: Draw a squiggly underline below the regions.
  • sublime.PERSISTENT: Save the regions in the session.
  • sublime.HIDDEN: Don't draw the regions.

The underline styles are exclusive, either zero or one of them should be given. If using an underline, sublime.DRAW_NO_FILL and sublime.DRAW_NO_OUTLINE should generally be passed in.



begin_edit ST2

ST2 begin_edit(<command>, <args>) # => Edit

Creates an edit object, demarcating an undo group. A corresponding call to end_edit() is required.



buffer_id ST2&3

ST2&3 buffer_id() # => int

Returns a number that uniquely identifies the buffer underlying this view.



change_count ST3

ST3 change_count() # => int

Returns the current change count. Each time the buffer is modified, the change count is incremented. The change count can be used to determine if the buffer has changed since the last it was inspected.



classify ST3

ST3 classify(point) # => int

Classifies point, returning a bitwise OR of zero or more of these flags:

  • sublime.CLASS_WORD_START
  • sublime.CLASS_WORD_END
  • sublime.CLASS_PUNCTUATION_START
  • sublime.CLASS_PUNCTUATION_END
  • sublime.CLASS_SUB_WORD_START
  • sublime.CLASS_SUB_WORD_END
  • sublime.CLASS_LINE_START
  • sublime.CLASS_LINE_END
  • sublime.CLASS_EMPTY_LINE



command_history ST2≠3

ST2 command_history(index, <modifying_only>) # => (String,Dict,int)

Returns the command name, command arguments, and repeat count for the given history entry, as stored in the undo / redo stack.

Index 0 corresponds to the most recent command, -1 the command before that, and so on. Positive values for index indicate to look in the redo stack for commands. If the undo / redo history doesn't extend far enough, then (None, None, 0) will be returned.

Setting modifying_only to True (the default is False) will only return entries that modified the buffer.



ST3 command_history(index, <modifying_only>) # => (str, dict, int)

Returns the command name, command arguments, and repeat count for the given history entry, as stored in the undo / redo stack.

Index 0 corresponds to the most recent command, -1 the command before that, and so on. Positive values for index indicate to look in the redo stack for commands. If the undo / redo history doesn't extend far enough, then (None, None, 0) will be returned.

Setting modifying_only to True (the default is False) will only return entries that modified the buffer.



em_width ST2≠3

ST2 em_width() # => real

Returns the typical character width used in the layout



ST3 em_width() # => float

Returns the typical character width used in the layout



encoding ST2≠3

ST2 encoding() # => String

Returns the encoding currently associated with the file



ST3 encoding() # => str

Returns the encoding currently associated with the file



end_edit ST2

ST2 end_edit(edit) # => Edit

Finishes the edit.



erase ST2≠3

ST2 erase(edit, region) # => None

Erases the contents of the region from the buffer.



ST3 erase(edit, region) # => None

Erases the contents of the region from the buffer.



erase_regions ST2&3

ST2&3 erase_regions(key) # => None

Removed the named regions



erase_status ST2&3

ST2&3 erase_status(key) # => None

Clears the named status.



expand_by_class ST3

ST3 expand_by_class(point, classes, <separators>) # => Region

Expands point to the left and right, until each side lands on a location that matches classes. classes is a bitwise OR of the sublime.CLASS_XXX flags. separators may be passed in, to define what characters should be considered to separate words.



ST3 expand_by_class(region, classes, <separators>) # => Region

Expands region to the left and right, until each side lands on a location that matches classes. classes is a bitwise OR of the sublime.CLASS_XXX flags. separators may be passed in, to define what characters should be considered to separate words.



extract_scope ST2≠3

ST2 extract_scope(point) # => Region

Returns the extent of the syntax name assigned to the character at the given point.



ST3 extract_scope(point) # => Region

Returns the extent of the syntax scope name assigned to the character at the given point.



file_name ST2≠3

ST2 file_name() # => String

The full name file the file associated with the buffer, or None if it doesn't exist on disk.



ST3 file_name() # => str

The full name file the file associated with the buffer, or None if it doesn't exist on disk.



find ST2≠3

ST2 find(pattern, fromPosition, <flags>) # => Region

Returns the first Region matching the regex pattern, starting from the given point, or None if it can't be found. The optional flags parameter may be sublime.LITERAL, sublime.IGNORECASE, or the two ORed together.



ST3 find(pattern, start_point, <flags>) # => Region

Returns the first region matching the regex pattern, starting from start_point, or None if it can't be found. The optional flags parameter may be sublime.LITERAL, sublime.IGNORECASE, or the two ORed together.



find_all ST2≠3

ST2 find_all(pattern, <flags>, <format>, <extractions>) # => [Region]

Returns all (non-overlapping) regions matching the regex pattern. The optional flags parameter may be sublime.LITERAL, sublime.IGNORECASE, or the two ORed together. If a format string is given, then all matches will be formatted with the formatted string and placed into the extractions list.



ST3 find_all(pattern, <flags>, <format>, <extractions>) # => [Region]

Returns all (non-overlapping) regions matching the regex pattern. The optional flags parameter may be sublime.LITERAL, sublime.IGNORECASE, or the two ORed together. If a format string is given, then all matches will be formatted with the formatted string and placed into the extractions list.



find_by_class ST3

ST3 find_by_class(point, forward, classes, <separators>) # => Region

Finds the next location after point that matches the given classes. If forward is False, searches backwards instead of forwards. classes is a bitwise OR of the sublime.CLASS_XXX flags. separators may be passed in, to define what characters should be considered to separate words.



find_by_selector ST2≠3

ST2 find_by_selector(selector) # => [Regions]

Finds all regions in the file matching the given selector, returning them as a list.



ST3 find_by_selector(selector) # => [Region]

Finds all regions in the file matching the given selector, returning them as a list.



fold ST2≠3

ST2 fold([regions]) # => bool

Folds the given regions, returning False if they were already folded



ST2 fold(region) # => bool

Folds the given region, returning False if it was already folded



ST3 fold([regions]) # => bool

Folds the given regions, returning False if they were already folded



ST3 fold(region) # => bool

Folds the given region, returning False if it was already folded



full_line ST2≠3

ST2 full_line(point) # => Region

As line(), but the region includes the trailing newline character, if any.



ST2 full_line(region) # => Region

As line(), but the region includes the trailing newline character, if any.



ST3 full_line(point) # => Region

As line(), but the region includes the trailing newline character, if any.



ST3 full_line(region) # => Region

As line(), but the region includes the trailing newline character, if any.



get_regions ST2≠3

ST2 get_regions(key) # => [regions]

Return the regions associated with the given key, if any



ST3 get_regions(key) # => [Region]

Return the regions associated with the given key, if any



get_status ST2≠3

ST2 get_status(key) # => String

Returns the previously assigned value associated with the key, if any.



ST3 get_status(key) # => str

Returns the previously assigned value associated with the key, if any.



hide_popup ST3

ST3 hide_popup() # => None

Hides the popup.



id ST2&3

ST2&3 id() # => int

Returns a number that uniquely identifies this view.



insert ST2≠3

ST2 insert(edit, point, string) # => int

Inserts the given string in the buffer at the specified point. Returns the number of characters inserted: this may be different if tabs are being translated into spaces in the current buffer.



ST3 insert(edit, point, string) # => int

Inserts the given string in the buffer at the specified point. Returns the number of characters inserted: this may be different if tabs are being translated into spaces in the current buffer.



is_auto_complete_visible ST3

ST3 is_auto_complete_visible() # => bool

Returns if the auto complete menu is currently visible.



is_dirty ST2≠3

ST2 is_dirty() # => bool

Returns true if there are any unsaved modifications to the buffer.



ST3 is_dirty() # => bool

Returns True if there are any unsaved modifications to the buffer.



is_loading ST2≠3

ST2 is_loading() # => bool

Returns true if the buffer is still loading from disk, and not ready for use.



ST3 is_loading() # => bool

Returns True if the buffer is still loading from disk, and not ready for use.



is_popup_visible ST3

ST3 is_popup_visible() # => bool

Returns if the popup is currently shown.



is_primary ST3

ST3 is_primary() # => bool

If the view is the primary view into a file. Will only be False if the user has opened multiple views into a file.



is_read_only ST2≠3

ST2 is_read_only() # => bool

Returns true if the buffer may not be modified.



ST3 is_read_only() # => bool

Returns True if the buffer may not be modified.



is_scratch ST2≠3

ST2 is_scratch() # => bool

Returns true if the buffer is a scratch buffer. Scratch buffers never report as being dirty.



ST3 is_scratch() # => bool

Returns True if the buffer is a scratch buffer. Scratch buffers never report as being dirty.



layout_extent ST2≠3

ST2 layout_extent() # => vector

Returns the width and height of the layout.



ST3 layout_extent() # => vector

Returns the width and height of the layout.



layout_to_text ST2≠3

ST2 layout_to_text(vector) # => point

Converts a layout position to a text position



ST3 layout_to_text(vector) # => point

Converts a layout position to a text position



line ST2≠3

ST2 line(point) # => Region

Returns the line that contains the point.



ST2 line(region) # => Region

Returns a modified copy of region such that it starts at the beginning of a line, and ends at the end of a line. Note that it may span several lines.



ST3 line(point) # => Region

Returns the line that contains the point.



ST3 line(region) # => Region

Returns a modified copy of region such that it starts at the beginning of a line, and ends at the end of a line. Note that it may span several lines.



line_endings ST2≠3

ST2 line_endings() # => String

Returns the line endings used by the current file.



ST3 line_endings() # => str

Returns the line endings used by the current file.



line_height ST2≠3

ST2 line_height() # => real

Returns the light height used in the layout



ST3 line_height() # => float

Returns the light height used in the layout



lines ST2≠3

ST2 lines(region) # => [Region]

Returns a list of lines (in sorted order) intersecting the region.



ST3 lines(region) # => [Region]

Returns a list of lines (in sorted order) intersecting the region.



match_selector ST3

ST3 match_selector(point, selector) # => bool

Checks the selector against the scope at the given point, returning a bool if they match.



name ST2≠3

ST2 name() # => String

The name assigned to the buffer, if any



ST3 name() # => str

The name assigned to the buffer, if any



overwrite_status ST3

ST3 overwrite_status() # => bool

Returns the overwrite status, which the user normally toggles via the insert key.



replace ST2≠3

ST2 replace(edit, region, string) # => None

Replaces the contents of the region with the given string.



ST3 replace(edit, region, string) # => None

Replaces the contents of the region with the given string.



rowcol ST2≠3

ST2 rowcol(point) # => (int, int)

Calculates the 0 based line and column numbers of the point.



ST3 rowcol(point) # => (int, int)

Calculates the 0-based line and column numbers of the point.



run_command ST2≠3

ST2 run_command(string, <args>) # => None

Runs the named TextCommand with the (optional) given arguments.



ST3 run_command(string, <args>) # => None

Runs the named TextCommand with the (optional) given args.



scope_name ST2≠3

ST2 scope_name(point) # => String

Returns the syntax name assigned to the character at the given point.



ST3 scope_name(point) # => str

Returns the syntax scope name assigned to the character at the given point.



score_selector ST2≠3

ST2 score_selector(point, selector) # => Int

Matches the selector against the scope at the given location, returning a score. A score of 0 means no match, above 0 means a match. Different selectors may be compared against the same scope: a higher score means the selector is a better match for the scope.



ST3 score_selector(point, selector) # => int

Matches the selector against the scope at the given point, returning a score. A score of 0 means no match, above 0 means a match. Different selectors may be compared against the same scope: a higher score means the selector is a better match for the scope.



sel ST2≠3

ST2 sel() # => RegionSet

Returns a reference to the selection.



ST3 sel() # => Selection

Returns a reference to the selection.



set_encoding ST2&3

ST2&3 set_encoding(encoding) # => None

Applies a new encoding to the file. This encoding will be used the next time the file is saved.



set_line_endings ST2&3

ST2&3 set_line_endings(line_endings) # => None

Sets the line endings that will be applied when next saving.



set_name ST2&3

ST2&3 set_name(name) # => None

Assigns a name to the buffer



set_overwrite_status ST3

ST3 set_overwrite_status(enabled) # => None

Sets the overwrite status.



set_read_only ST2&3

ST2&3 set_read_only(value) # => None

Sets the read only property on the buffer.



set_scratch ST2&3

ST2&3 set_scratch(value) # => None

Sets the scratch property on the buffer.



set_status ST2≠3

ST2 set_status(key, value) # => None

Adds the status key to the view. The value will be displayed in the status bar, in a comma separated list of all status values, ordered by key. Setting the value to the empty string will clear the status.



ST3 set_status(key, value) # => None

Adds the status key to the view. The value will be displayed in the status bar, in a comma separated list of all status values, ordered by key. Setting the value to the empty string will clear the status.



set_syntax_file ST2≠3

ST2 set_syntax_file(syntax_file) # => None

Changes the syntax used by the view. syntax_file should be a name along the lines of Packages/Python/Python.tmLanguage. To retrieve the current syntax, use view.settings().get('syntax').



ST3 set_syntax_file(syntax_file) # => None

Changes the syntax used by the view. syntax_file should be a name along the lines of Packages/Python/Python.tmLanguage. To retrieve the current syntax, use view.settings().get('syntax').



set_viewport_position ST2&3

ST2&3 set_viewport_position(vector, <animate<) # => None

Scrolls the viewport to the given layout position.



settings ST2≠3

ST2 settings() # => Settings

Returns a reference to the views settings object. Any changes to this settings object will be private to this view.



ST3 settings() # => Settings

Returns a reference to the view's settings object. Any changes to this settings object will be private to this view.



show ST2≠3

ST2 show(point, <show_surrounds>) # => None

Scroll the view to show the given point.



ST2 show(region, <show_surrounds>) # => None

Scroll the view to show the given region.



ST2 show(region_set, <show_surrounds>) # => None

Scroll the view to show the given region set.



ST3 show(location, <show_surrounds>) # => None

Scroll the view to show the given location, which may be a point, Region or Selection.



show_at_center ST2≠3

ST2 show_at_center(point) # => None

Scroll the view to center on the point.



ST2 show_at_center(region) # => None

Scroll the view to center on the region.



ST3 show_at_center(location) # => None

Scroll the view to center on the location, which may be a point or Region.



show_popup ST3

ST3 show_popup(content, <flags>, <location>, <max_width>, <max_height>, <on_navigate>, <on_hide>) # => None

Shows a popup displaying HTML content.

flags is a bitwise combination of the following:

  • sublime.COOPERATE_WITH_AUTO_COMPLETE. Causes the popup to display next to the auto complete menu
  • sublime.HIDE_ON_MOUSE_MOVE. Causes the popup to hide when the mouse is moved, clicked or scrolled
  • sublime.HIDE_ON_MOUSE_MOVE_AWAY. Causes the popup to hide when the mouse is moved (unless towards the popup), or when clicked or scrolled

The default location of -1 will display the popup at the cursor, otherwise a text point should be passed.

max_width and max_height set the maximum dimensions for the popup, after which scroll bars will be displayed.

on_navigate is a callback that should accept a string contents of the href attribute on the link the user clicked.

on_hide is called when the popup is hidden.



show_popup_menu ST3

ST3 show_popup_menu(items, on_done, <flags>) # => None

Shows a pop up menu at the caret, to select an item in a list. on_done will be called once, with the index of the selected item. If the pop up menu was cancelled, on_done will be called with an argument of -1.

items is a list of strings.

flags it currently unused.



size ST2&3

ST2&3 size() # => int

Returns the number of character in the file.



split_by_newlines ST2≠3

ST2 split_by_newlines(region) # => [Region]

Splits the region up such that each region returned exists on exactly one line.



ST3 split_by_newlines(region) # => [Region]

Splits the region up such that each region returned exists on exactly one line.



substr ST2≠3

ST2 substr(region) # => String

Returns the contents of the region as a string.



ST2 substr(point) # => String

Returns the character to the right of the point.



ST3 substr(region) # => str

Returns the contents of the region as a string.



ST3 substr(point) # => str

Returns the character to the right of the point.



symbols ST3

ST3 symbols() # => [(Region, str)]

Extract all the symbols defined in the buffer.



text_point ST2≠3

ST2 text_point(row, col) # => int

Calculates the character offset of the given, 0 based, row and column. Note that 'col' is interpreted as the number of characters to advance past the beginning of the row.



ST3 text_point(row, col) # => int

Calculates the character offset of the given, 0-based, row and col. Note that col is interpreted as the number of characters to advance past the beginning of the row.



text_to_layout ST2≠3

ST2 text_to_layout(point) # => vector

Converts a text position to a layout position



ST3 text_to_layout(point) # => vector

Converts a text position to a layout position



unfold ST2≠3

ST2 unfold(region) # => [regions]

Unfolds all text in the region, returning the unfolded regions



ST2 unfold([regions]) # => [regions]

Unfolds all text in the regions, returning the unfolded regions



ST3 unfold(region) # => [Region]

Unfolds all text in the region, returning the unfolded regions



ST3 unfold([regions]) # => [Region]

Unfolds all text in the regions, returning the unfolded regions



update_popup ST3

ST3 update_popup(content) # => None

Updates the contents of the currently visible popup.



viewport_extent ST2≠3

ST2 viewport_extent() # => vector

Returns the width and height of the viewport.



ST3 viewport_extent() # => vector

Returns the width and height of the viewport.



viewport_position ST2≠3

ST2 viewport_position() # => Vector

Returns the offset of the viewport in layout coordinates.



ST3 viewport_position() # => vector

Returns the offset of the viewport in layout coordinates.



visible_region ST2≠3

ST2 visible_region() # => Region

Returns the currently visible area of the view.



ST3 visible_region() # => Region

Returns the currently visible area of the view.



window ST2≠3

ST2 window() # => Window

Returns a reference to the window containing the view.



ST3 window() # => Window

Returns a reference to the window containing the view.



window_to_layout ST3

ST3 window_to_layout(vector) # => vector

Converts a window position to a layout position



window_to_text ST3

ST3 window_to_text(vector) # => point

Converts a window position to a text position



word ST2≠3

ST2 word(point) # => Region

Returns the word that contains the point.



ST2 word(region) # => Region

Returns a modified copy of region such that it starts at the beginning of a word, and ends at the end of a word. Note that it may span several words.



ST3 word(point) # => Region

Returns the word that contains the point.



ST3 word(region) # => Region

Returns a modified copy of region such that it starts at the beginning of a word, and ends at the end of a word. Note that it may span several words.




Generated from the official documentation on Sat Oct 29 20:16:54 EEST 2016 by Leonid Shevtsov.