Sublime Forum

Show total number of lines (lines count) in statusbar

#1

Is there a way to show the total number of lines (lines count) in the opened file in the status bar? Thanks!

0 Likes

#2

A small plugin can do that

import sublime
import sublime_plugin

class ShowFileLineListener(sublime_plugin.ViewEventListener):

    def __init__(self, view):
        self.view = view

    def on_load_async(self):
        line_count = len(self.view.lines(sublime.Region(0, self.view.size())))
        self.view.set_status("line_count", "Lines: {}".format(line_count))

    def on_close(self):
        if self.view.get_status("line_count"):
            self.view.erase_status("line_count")

    on_activated = on_load_async
    on_deactivated = on_close
0 Likes

#3

Thanks but, how do I implement the code shown above? Is there a plugin or package already available that does this? Is there not a setting in ST that can accomplish this?

0 Likes

#4

Copy the code given, then watch this video for further instructions.

0 Likes

#5

Thank you!

0 Likes