Home Download Buy Blog Forum Support

How to highlight block of code

How to highlight block of code

Postby RaulM on Mon Apr 01, 2013 10:07 am

Image

Do anybody know how to highlight blocks of text as with the image above?

Here is the link again should the other image doesnt work. Thanks all.
RaulM
 
Posts: 2
Joined: Mon Apr 01, 2013 10:00 am

Re: How to highlight block of code

Postby robertcollier4 on Mon Apr 01, 2013 11:30 am

Push Ctrl+` to load the console to test the following command. It will highlight the current selection with the coloring for scope "string" as defined in your color scheme. You can make it into a plugin command and then assign a key binding to that plugin command.

Code: Select all
view.add_regions("highlightkeytest", view.sel(), "string")


http://www.sublimetext.com/docs/2/api_reference.html
add_regions(key, [regions], scope, <icon>, <flags>)
The scope is used to source a color to draw the regions in, it should be the name of a scope, such as "comment" or "string". If the scope is empty, the regions won't be drawn.
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: How to highlight block of code

Postby RaulM on Wed Apr 03, 2013 2:08 pm

Thanks for replying Robert.

I dont get it yet, I have tried to put the following code into the console.
Code: Select all
view.add_regions("highlightkeytest", view.sel(), "string")
I just get the following error.
Code: Select all
Boost.Python.ArgumentError: Python argument types in
    View.add_regions(View, str, RegionSet, str)
did not match C++ signature:
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, int)
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, int)
>>> add_regions("highlightkeytest", view.sel(), "string")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'add_regions' is not defined


Im not experienced using this sort of coding language at all, but i think that highlighting certain areas with code they way it shows in the screenshot above could be very handy.

Will you explain the steps for the highlight feature please.

Thanks.
RaulM
 
Posts: 2
Joined: Mon Apr 01, 2013 10:00 am

Re: How to highlight block of code

Postby skuroda on Mon Apr 08, 2013 12:06 am

Change your statement to
Code: Select all
view.add_regions("highlightkeytest", list(view.sel()), "string")


What are you trying to do?
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am


Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 113 guests