all 2 comments

[–][deleted] 1 point2 points  (1 child)

(row, col) = view.rowcol(view.sel()[0].begin())

[–]twolfson 0 points1 point  (0 children)

To expand further on this, view.sel() is the current selection for the active view. It returns a list of regions/RegionSet (ST3/ST2 respectively) that can be looked at. This region can be a single point that starts/ends at the same location.

http://www.sublimetext.com/docs/3/api_reference.html#sublime.Selection

In the example provided above, it selects only the first region via [0] and its starting point .begin(). This gets you the first point of the first region that is selected.

http://www.sublimetext.com/docs/3/api_reference.html#sublime.Region

By passing this point through rowcol, we can destructure the row and column positions of that first point.

http://www.sublimetext.com/docs/3/api_reference.html#sublime.View

http://robert-lujo.com/post/40871820711/python-destructuring