textmate bundles not recognizing differences - textmate

So i'm trying to make a set of grammars recognizing different file extensions properly.
All my files (js/css/html) end with template. This is similiar to how ruby does it with js.erb, css.erb, etc. So I modified the file type attribute to js.template css.template and template itself for html. But it doesn't seem to work. They just default to template even though there are more specific ones.
But for some reason Textmate doesn't want to recognize my different file extensions. Any idea why this would be happening or why the Ruby grammars seem to work but mine don't?

The detailed answer depends on the scope and therefore syntax highlighting you want. The general approach is as follows:
Open the Bundles Editor (Control-Meta-Command-B)
Search for the language definition of JavaScript, i.e. in the JavaScript bundle is a grammar definition called "JavaScript"
Open it and look for the line which starts with "filetypes", which should look like fileTypes = ( 'js', 'htc', 'jsx' );
Add your own file ending, i.e. "js.template"
Close the Bundle Editor or activate another snippet / command / grammar or click the Test button to reload the grammar (note that manual language definitions are preferred over file ending, so create a new file with that extension and load it with TextMate to make sure it works)
Repeat for any grammar definition you want to work with another file ending, i.e. HTML and CSS
This way you will have the default syntax highlighting working in your files with .template endings. However, the Ruby on Rails bundle extends those grammars a little, so maybe you want to extend the supported filetypes of these grammars as well.

Related

Change language mode for multiple files

apologies if this is a silly question, but does anyone know if it's possible to change the language mode for a bunch of files at once? I'm working on a project with hundreds of Jinja templates, but as all the files are .html I have to manually switch the language mode for each one to get the correct syntax highlighting.
Ideally I'd just like to select them all in the file sidebar and update the language settings for each file, but I imagine pretty much any solution would be quicker than the current method!
Cheers! :)
VSC does not store the languageId of the file, it uses the file extension that can be overruled by a setting.
Add this to your project settings in .vscode/settings.json
"files.associations": {
"*.html": "jinja"
}

Add a new code style on PhpStorm

I have started using Semantic UI and I noticed that when I want to customize my css, I need to make .variables and .overrides files. Their syntax is just like .less syntax, but they're treated differently by their types.
What I want now, is when I open a .variables or a .overrides files, PhpStorm will treat it as a less code style. Is it possible to achieve it?
If there's an option to do per Project, it'll be perfect.

Is there an editor (or a solution for kate) doing syntax highlighting in a mixed code?

I'm using Kate as the editor of my Node.js projects. In the Node.js projects, I sometimes prefer to code whole index.html in a single file. At that time, I need to use:
html
css (<style>...</style>)
livescript (<script type="text/ls">...</script>)
javascript (<script [type="text/javascript"]>...</script>)
at the same time. Kate can highlight these codes if they are in their separate files.
How can I make the code highlighted correctly when they are mixed in a single file (preferably in Kate, or any other editor that would run on Linux)?
Kate can do this, too. It is supported in e.g. HTML/PHP highlighting and similar. Just have a look into the respective highlighting xml files to get an idea how to implement a highlighting for this. More information about how to write syntax highlighting files can be found in the KatePart Handbook.

What is the equivalent of re-formatting and checking syntax on save of Textmate in SublimeText2?

I recently switched to SublimeText2 from Textmate and I've been enjoying it.
But there are some features of Textmate which I don't know for SBT2.
Selecting a block of code and pressing CMD+OPTION+[ re-formats the selected block.
While saving a file CMD+S, ruby or jquery or coffee-script, etc.. Texmate checks the syntax of the code.
How to do the same with SBT2?
To check syntax on save you can use SublimeLinter and to reformat code you can use something like the following depending on what languages you work with:
HTMLTidy
Sublime-HTMLPrettify (HTML, JS, CSS)
Pretty JSON
PHPTidy
PythonTidy
BeautifyRuby
There are plenty of other similar and other useful extensions and plugins here: http://wbond.net/sublime_packages/community
All of which can be easily installed and kept up to date using Package Control.

Markdown syntax highlighting in SciTE/Notepad++

I'm looking for a .properties file for Markdown syntax in SciTE. Is it possible?
A partial highlighter would do, otherwise.
I'm using this syntax file: https://github.com/leafnode/markdown_npp with some color changes to fit dark background.
I've uploaded my (dark) user-defined language Markdown highlighter on GitHub. It uses different workarounds than thomsmits', which for the style of Markdown I've chosen work better.
Until the Markdown Scintilla lexer is imported into Notepad++, user defined languages are the best we can do.
I don't use Notepad++ any more and have deleted my project. Try Brettz9's fork of the project here: https://github.com/brettz9/Notepad---Markdown-Highlighting
I'm using Markdown-plus-plus. The install instruction is outdated on many projects. The actual instruction is:
Select menu "Language" → "Define your language..."
Press button "Import...", and select {markdown}.xml (from GitHub repositories).
Restart Notepad++
I believe somebody mentioned on the mailing list that he is working on such a lexer.
I don't think a simple .properties file can do the job, as there isn't any existing lexer (to my knowledge) with similar syntax.

Resources