Home Download Buy Blog Forum Support

Ruby #{} highlighting

Ruby #{} highlighting

Postby richardjortega on Thu Feb 09, 2012 5:21 am

I'm a fairly newcomer to SublimeText2 and I've searched high and low for this answer and couldn't find a concrete solution. I prefer SublimeText2 over TextMate and would like to include #{} syntax highlighting for Ruby.

Any help appreciated!!
richardjortega
 
Posts: 1
Joined: Fri Jan 13, 2012 5:04 pm

Re: Ruby #{} highlighting

Postby sublimator on Thu Feb 09, 2012 5:32 am

<dict>
<key>name</key>
<string>Embedded Ruby Punctuation</string>
<key>scope</key>
<string>string punctuation.section.embedded.ruby</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F92672</string>
</dict>
</dict>

You could add a section like the above to the `Packages/Color Scheme - Default/Monokai.tmTheme` file, adjusting color to taste.

"Then the punctuation should be highlighted #{ 2 + 2 }"


"And without any #{ 2 + 2 }"
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: Ruby #{} highlighting

Postby C0D312 on Thu Feb 09, 2012 11:39 pm

@castles, how long did it take you to add all that highlighting? Be honest :)
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Ruby #{} highlighting

Postby sublimator on Fri Feb 10, 2012 12:27 am

settings = sublime.load_settings('html-export.sublime-settings')

defaults
= {
"open_html_in_editor" : False,
"open_html_in_browser" : True,
"copy_css_to_clipboard" : False,
"copy_html_to_clipboard" : True,
"encode_as" : "utf-8",
"add_line_numbers" : False,
"root_node" : "pre",
'use_style' : True,
'bulletin_board' : True,
}


def memoize(func):
"Implementation taken from python test suite"
saved
= {}
def call(*args):
try:
return saved[args]
except KeyError:
res
= func(*args)
saved[args]
= res
return res
except TypeError:
# Unhashable argument
return func(*args)
call.func_name
= func.func_name
return call


A few milliseconds, it uses memoization.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: Ruby #{} highlighting

Postby sublimator on Fri Feb 10, 2012 12:48 am

Oh, and stop giving me shit and apply for the Google Summer of Code already you young upstart.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: Ruby #{} highlighting

Postby C0D312 on Fri Feb 10, 2012 12:50 am

hahahahaha :) alright already...
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 28 guests