Sublime Forum

How to obtain the line number of the current cursor for a self-developed plug-in?

#1

import sublime
import sublime_plugin

class LinjumingCommand(sublime_plugin.TextCommand):
def run(self, edit):
lineNum = xxxx ?

0 Likes

#2

See sublime.View.rowcol

1 Like

#3

tank you,try success

import sublime
import sublime_plugin

class LinjumingCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    sel = self.view.sel()
    region = self.view.sel()[0]
    lineNum = self.view.rowcol(region.begin())[0]
    print(lineNum)
0 Likes