Sublime Text 2: How to set up consistent syntax highlighting for Guardfile? - ruby-on-rails

While it is easy enough to set the language for a given (open) file in Sublime Text, I'm wondering if there is any way that I can tell the editor in advance that anything called "Guardfile" should be highlighted like it's Ruby code. Does anyone know how to do this?

The plugins recommended in the comments by Brian both do the job nicely:
ApplySyntax
SyntaxFromFileName
Update:
I couldn't get SyntaxFromFileName to match any of my regex for some reason. On the other hand, DetectSyntax comes with syntax highlight for the Guardfile built in.
Update2:
DetectSyntax has been renamed to ApplySyntax

Putting the following at the top of said file also works
#!/usr/bin/env ruby

Related

DokuWiki: Highlight Part in code Block?

I want to highlight/emphasize a part in a code block in dokuwiki.
I could not find a hint in the docs: https://www.dokuwiki.org/wiki:syntax#code_blocks
But maybe I am missing something.
Background: I am not searching for syntax highlighting. I want to emphasize a part.
That's not possible. There are alternative highlight plugins (code2 seems to be popular) that might be able to do that.

"ESC" Character in test.log when viewed in Sublime

Whenever I open up test.log from any rails application I get the following screenshot in Sublime. I've tried messing around with encodings, but couldn't find anything that fixed it.
Any ideas on what is going on?
These are control characters used to add colour to the log files. Sublime text apparently doesn't support this.
If you're mostly going to be viewing log files with editors that don't understand these colour codes you can turn this off with the rails config.colorize_logging setting
There's a Sublime package to turn these ANSI/vt100 escape sequences into colored text -- SublimeANSI
(use Package Control and look for ANSIescape) -- this adds an "ANSI" file type that will display your log file in glorious color. (The file is displayed read-only but you can change the type back to "Plain Text" if you want to edit it.)
Backing up Tom Hundt's answer... SublimeANSI is the way to go. Compare these before/after shots:
Sublime's default rendering of colorized Rails log output:
Now change the syntax highlighting to ANSI:
Now, marvel in the majesty of SumblimeANSI's rendering:
Learn more about SublimeANSI package at: https://github.com/aziz/SublimeANSI
Note: To install it in Package Manager, search for "ANSIescape" ... NOT "SublimeANSI". This confused me for a hot minute.

SublimeText 2 Ruby formatting

Has anyone found a good Ruby/Rails formatter? There is BeautifyRuby, but it gets strings written like Q%[] wrong because it aligns everything to the [] and it messes everything up.
Essentially it looks like this from a function auto formatted by beautifyruby:
%x[#{cat_command} &]
%x[#{join_command} &]
return newintroname
end
Does anyone have an idea how to fix this?
The current version of beautifyRuby actually solves this problem.
I recommend you to use RuboCop to find all the issues/suggestions/alternatives/good practices in Ruby. It is also available as a Sublime Text plugin.
Ruby Good Practices: https://github.com/bbatsov/ruby-style-guide

Notepad++: block comment not working

I am running Notepad++ 5.8.5 on Windows 7, editing Perl programs.
I would like to comment out a block of text lines (and later, perhaps, uncomment it).
None of the following works:
CTRL+K, CTRL+Q, CTRL+shift+K, CTRL+shift+Q,
selecting the block of lines and going to the menu: edit-> Comment/Uncomment -> Block Comment
none of the above has any effect.
What to do?
Is NP++ interpreting your file as Perl or plain text?
If NP++ is treating your file as plain text, then language specific things like that won't work.
You may want to double-check that as described here.
Why not try updating to a newer version? That's horribly out of date (a year old).
Define your own language to match to the file extension, in your case it is: txt
and then define any comment style you want. Then close and open NP++ again. Enjoy!
Path: Language--->Define your Language --> Comments & Number tab
Hank Wei

Is there a shortcut in Textmate to wrap selection with multiline comment?=begin and =end

I want a shortcut in Textmate to wrap the selected text with a ruby multiline comment -- '=begin' and '=end'.
It doesn't look like there is an existing one. Anyone know how to make one?
Finally figure it out, mostly by luck. I still wish I could find where the shortcut was defined.
However, it's ⌥⌘/
My bundle always uses the single-line comments, even when I select multiple lines. I'm sure your answer lies somewhere in Bundles > Bundle Editor > Ruby > Comments.

Resources