Sublime Forum

Highlight line in editor?

#1

Hi all, I’m working on a plugin and it does stuff (yay), my next step is to display this to the user.

Basically, I’ve been searching for a way to highlight a line in the editor, I haven’t been able to find any info on how to highlight a line in the editor (And of course, how to reset it), could someone point me in the right direction?

0 Likes

#2

I do this so:

def show_viewport(region): view = sublime.active_window().active_view() vector = view.text_to_layout(region.a) view.set_viewport_position(vector) view.sel().clear() view.sel().add(sublime.Region(region.b))
The given region includes only one line.
To reset: clear the selection again.

0 Likes

#3

Thanks mate, I’ll give that a shot (Not on the dev box at the moment)

0 Likes

#4

I finally had a chance to try this, granted I may not be passing in the right info, but all it does (The only thing I’ve gotten to work) is where it scrolls to the position.

0 Likes

#5

I should say, I’m going through and checking for errors line by line, so what I’m passing in is the current line (Which it scrolls to)

0 Likes

#6

This code piece scrolls to the position

view.set_viewport_position(vector)

This one selects a line

view.sel().add(view.line(point))

Check out the API Reference for further infos:
sublimetext.com/docs/3/api_reference.html

0 Likes

#7

I may not be passing in the right info, but all it does (The only thing I’ve gotten to work) is where it scrolls to the position.??

0 Likes