Bumping an old thread thats incorrectly categorized. A quick toggle to index the columns/lines from 0 (instead of 1) would be nice. If there is already a plugin covering this, please link me!
0-Indexed Lines/Columns
deathaxe
#2
ST’s default “Line: … Column: …” can be disabled via "show_line_column": "disabled",
and replaced by plugin.
Example:
Create a Packages/User/my_line_count.py
with the following content:
import sublime
import sublime_plugin
class LineCountListener(sublime_plugin.EventListener):
"""
This class describes a line count listener.
Note: Set ``"show_line_column", "disabled"``
to disable ST's built-in line/column status
"""
def on_new(self, view: sublime.View):
"""
Update status for new view.
"""
self._update(view)
def on_load(self, view: sublime.View):
"""
Update status after loading file.
"""
self._update(view)
def on_selection_modified(self, view: sublime.View):
"""
Update status when caret moves.
"""
self._update(view)
def _update(self, view: sublime.View):
sel = view.sel()
if not sel:
view.set_status("zzz_lines", "")
return
pt = sel[0].begin()
row, col = view.rowcol(pt)
view.set_status("zzz_lines", f"L: {(row)}, C: {col}")
0 Likes