Hack: Modifying Tabinta to insert spaces instead of a tab character
I recently began using Bálint Endrey’s very helpful Tabinta Firefox add-on. From the addons.mozilla.org page for the extension:
Tabinta lets you insert tab characters in multi-line text input fields. The name itself is a shorthand for “Tab in Textarea”.
The default tab key behavior in Mozilla/Firefox textareas is to go to the next form field. This extension is for people who prefer inserting actual tab characters into these fields.
I prefer to use spaces for indentation rather than tab characters and posted a thread (Spaces instead of tabs) asking whether he’d considered adding an option for a configurable number of spaces to be inserted when the tab key was pressed instead of a tab character. He hadn’t yet replied (this is not a complaint at all - I don’t really check forums on sites where some of my code is hosted/distributed from very often - we all lead busy lives - etc.), so I decided to crack the XPI open and see if I could make a change.
The XPI is just a ZIP archive, so I extracted it. Inside the chrome/ subdirectory, there’s another archive, tabinta.jar. I extracted that and looked inside. content/tabinta contained a file that looked promising, tabintaOverlay.js (that’s chrome/content/tabinta/tabintaOverlay.js).
It contained the function insertTab:
insertTab: function(element) {
tabinta_insertText(element, "\t");
},
All I had to do was replace the \t with four spaces, recreate the JAR, clean up the un-archived files from the JAR, recreate the XPI, and then uninstall the original version of the add-on and install my modified version and …. voila! Four spaces instead of a tab character when I press the Tab key inside of TEXTAREAs.