Netbeans : Only using space tabs for python

I like to use tab as separator for all my files (html/css/js) but it is recommended to use space tabulation for python files.

With netbeans, the problem is if you go in the preferences :

Tools > Options > Editor > Formatting

you can see the parameter "Expand tabs to spaces" when you are using "Language : All Languages" and "Category : Tabs and Indents" (Of course, I didn't checked this one in order to have tabs and not space).

But, now if you choose Python as Language, there is no "Tabs and Indents" category.

So by default, you had to choose to expand tabs to space for all your files in order to have the python files to work.

But I've found the solution to just using space for python files, and tab for the rest.

All you have to do is to add the following lines to the file

[Netbeans Installed Folder]/.netbeans/6.8/config/Editors/text/x-python/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml
<entry javaType="java.lang.String" name="code-template-expand-key" xml:space="preserve">
        <value><![CDATA[TAB]]></value>
    </entry>
    <entry javaType="java.lang.Boolean" name="expand-tabs" xml:space="preserve">
        <value><![CDATA[true]]></value>
    </entry>

Restart your editors and that's it ! You can now have space for python and tabs for the rest of your script files !

Hope this helps !

Posted by Cyril Nicodème