Sublime Forum

Status bar: character number of this line

#1

The status bar shows the line and column numbers of the cursor. Which is good. Is it possible for the status bar to show also the character number of this line?

Without tabs, the character number will typically equal the column number. Each tab is is only 1 character, but (for me at least), each tab is 4 columns.

0 Likes

#2

Tool > Developer > New Plugin…

import sublime_plugin


class ShowLineCharPos(sublime_plugin.EventListener):
    def on_selection_modified_async(self, view):
        self.showLineCharPos(view)

    def on_activated_async(self, view):
        self.showLineCharPos(view)

    def showLineCharPos(self, view):
        w = view.window()
        sels = view.sel()

        if len(sels) == 1:
            row, col = view.rowcol(sels[0].b)
            w.status_message('pos: {}'.format(col))
        else:
            w.status_message('')
1 Like

#3

Thank you. That works.

Slightly inconsistent punctuation (semi-colon, comma) but very useful. Thank you.

0 Likes