Reputation: 6940
I'm really trying to associate the various .erb
filetypes. I would like to be able to associate .css.erb
and .scss.erb
with CSS, .html.erb
with HTML, and .js.erb
with JavaScript. Associating all .erb
files with HTML does fine for HTML files themselves, but it doesn't work very well for JavaScript, CSS, or SCSS.
I've tried putting css.erb
, etc. in the "User ext.:" box within the Style Configurator dialog, but it doesn't seem to pick up on the files properly.
I'm skeptical that this is possible, because I imagine the engine matches from the last .
to the end of the filename rather than, e.g., something like filename.endswith(ext)
, but I thought it worthwhile to ask if anyone has found a way to make it work.
Any thoughts?
Upvotes: 6
Views: 2302
Reputation: 241
In general, this is not possible (unless someone writes/has written a plugin for it); the entered extension only matches the part of the filename after the last dot as you have found.
So if you enter an extension that includes a dot, it unfortunately doesn't match files with double extensions. But entered extensions that include a dot has a separate behavior that might be useful to some extent: they match the whole filename.
I found this as I use a User Defined Language for the todo.txt format. The User Defined Language specifies the extension as todo.txt
, and it does match files named exactly todo.txt
.
I was interested in your question, because I wanted other files to use this language highlighting as well. E.g. I renamed done.txt
to done.todo.txt
and created files like projects.todo.txt
, 2021.todo.txt
, hoping they would use the todo.txt language highlighting, but as you have found out, it doesn't work.
But since I only have a limited number of such filenames, knowing that it can match the whole filename still helped me; I simply added additional extensions, e.g. done.txt
, projects.txt
, 2021.todo.txt
etc., for all filenames I would be using. It is still a clunky solution and I would have preferred a way to match all files ending with .todo.txt
and name my files accordingly; but it works for now and is better than selecting the language every time I reopen the file. (I could have removed the .txt
part and use .todo
as the extension as an easier solution, but I wanted to keep .txt
so that other programs continue to recognize them as text files.)
In your case, this solution is less useful, as you probably have a myriad of different filenames that end with .css.erb
and .html.erb
. But it might be still better than nothing if there are files that you work on frequently (currentproject.css.erb
), or there are common filenames (say index.html.erb
). You could just add each of those filenames, so that you could avoid having to select language manually at least on those files.
Upvotes: 1
Reputation: 24627
foo.css
for CSSfoo.css.erb
After using the Style Configurator, I have the following in the stylers.xml
file in the folder where the Notepadd++ executable is installed:
<LexerType ext="css.erb" desc="CSS" name="css">
<WordsStyle name="DEFAULT" fontSize="" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="0"/>
<WordsStyle name="TAG" fontSize="" fontStyle="0" fontName="Batang" bgColor="FFFFFF" fgColor="0000FF" styleID="1"/>
<WordsStyle name="CLASS" fontSize="" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="FF0000" styleID="2"/>
<WordsStyle name="PSEUDOCLASS" fontSize="" fontStyle="1" fontName="" bgColor="FFFFFF" fgColor="FF8000" styleID="3"/>
<WordsStyle name="UNKNOWN_PSEUDOCLASS" fontSize="" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="FF8080" styleID="4"/>
<WordsStyle name="OPERATOR" fontSize="" fontStyle="1" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="5"/>
<WordsStyle name="IDENTIFIER" fontSize="" fontStyle="1" fontName="" bgColor="FFFFFF" fgColor="8080C0" styleID="6" keywordClass="instre1"/>
<WordsStyle name="UNKNOWN_IDENTIFIER" fontSize="" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="7"/>
<WordsStyle name="VALUE" fontSize="" fontStyle="1" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="8"/>
<WordsStyle name="COMMENT" fontSize="" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="008000" styleID="9"/>
<WordsStyle name="ID" fontSize="" fontStyle="1" fontName="" bgColor="FFFFFF" fgColor="0080FF" styleID="10"/>
<WordsStyle name="IMPORTANT" fontSize="" fontStyle="1" fontName="" bgColor="FFFFFF" fgColor="FF0000" styleID="11"/>
<WordsStyle name="DIRECTIVE" fontSize="" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="0080FF" styleID="12"/>
</LexerType>
You can add more for each variation of erb by copying the model from stylers.model.xml
and following the pattern.
References
Upvotes: 1