Sublime Forum

Get the correct column number

#1

Does anybody know to get the correct column number the cursor is on?
I’ve tried using the view class rowcol(point) api but it only seems to work if there is text on the line If the cursor is sitting on a blank line I get a column return of 1 when my cursor (single cursor) is in column 5. The rowcol api does seem to give back the correct line number. Anybody know how to access the code the status bar uses?

Thanks

0 Likes

#2

Calling view.rowcol(view.sel()[0].a) returns correct 0-based cursor column even on blank only lines (space indention).

If I try the same with indention set to tabs, it returns the column as amount of tabs. With 2 tabs added, it returns 2 even though the column was 8 spaces

You can have a look into the Default packages indention.py to learn about how to calculate the “visual column”.

1 Like