Sublime Forum

Underline

#1

Hi,

I search how underline a word with sublime text.

Someone help ?

Thanks

0 Likes

Changing text line color
#2

Underline isn’t available yet I’m afraid.

0 Likes

#3

Not true, it can be done via add_regions:

    v = sublime.active_window().active_view()
    v.add_regions("hello", [sublime.Region(0,v.size())], "somescope","", sublime.DRAW_SOLID_UNDERLINE|sublime.DRAW_NO_FILL|sublime.DRAW_NO_OUTLINE)
0 Likes

#4

You can also get a solid underline (with no word breaks) by underlining a list of empty regions (one zero-width pos each, for the width of your underline) and the add_regions flag “sublime.DRAW_EMPTY_AS_OVERWRITE”.

This has been working since 2011.

1 Like

#5

[quote=“quarnster”]Not true, it can be done via add_regions:

v = sublime.active_window().active_view() v.add_regions("hello", [sublime.Region(0,v.size())], "somescope","", sublime.DRAW_SOLID_UNDERLINE|sublime.DRAW_NO_FILL|sublime.DRAW_NO_OUTLINE) [/quote]

How can I get the list of the “somescope” ? I just had some try and found a scope named “keyword”
I searched the API documentation and the google but failed.

I found the “view.scope_name(view.sel()[0].begin())” will get some king of “scope_name”, but it’s a long text like “source.python meta.function.python meta.function.parameters.python variable.parameter.function.python”, I extracted some words like “variable”, “parameter”, but no other color appeared

0 Likes

#6

Underline works:

sublime.active_window().active_view().add_regions(‘keyword’, [sublime.Region(0, sublime.active_window().active_view().size())], ‘b’, ‘’, sublime.DRAW_SOLID_UNDERLINE|sublime.DRAW_NO_FILL|sublime.DRAW_NO_OUTLINE)

0 Likes

Changing text line color