How do I get Komodo to use language-specific indentation levels? We use 2-space indentation for Ruby and HTML, 1-space for XML, and 4-space for everything else.
Time for another one of those tips to play with this weekend...
There are various internal reasons why Komodo doesn't have language-specific
indentation settings, but that hasn't stopped many people from asking for them.
However, this is a snap to implement with Komodo's trigger macros. Create
a new macro, and do the following:
1. Press the Triggers tab
2. Check "Macro should trigger on a Komodo event"
3. Select the "After file open" radio button.
You can have more than one trigger macro on a given event. The lower
the assigned rank, the later it fires. Your macros can even define
variables and functions into Komodo's global namespace, so an early-firing
macro could set a value that a later-firing one could use.
4. Finally, this code will control the indentations on load:
var language = komodo.document.languageObj.name;
// alert("Doc language = " + language );
var indentWidth = null;
switch(language) {
case 'XML':
indentWidth = 1;
break;
case 'Ruby':
case 'RHTML':
case 'HTML':
indentWidth = 2;
break;
}
if (indentWidth) {
komodo.document.indentWidth = indentWidth;
}The only problem with this trigger is that if you choose a
different indentation for a particular buffer, it will be
reset to the language default every time you load it.
I'll have to figure that one out.