Community
Participate
Working Groups
Go to the prefences page "C/C++ -> Editor", and tick "Insert space for tabs". Now open a C source file, indent somewhere, type "switch", hit CTRL+Space, and choose to insert a switch-case-statement. Now inspect the characters that have been inserted for indentation. You only find tabs. Those that came from the template itself are OK, but those that indent the whole template to fit the rest of the code should be spaces. Suggestion: In package org.eclipse.cdt.internal.corext.template.c you find CFormatter.java. in method "private void indent", change ############################################################################# String indent= Strings.createIndentString(fInitialIndentLevel); ############################################################################# to ############################################################################# boolean useSpaces= CUIPlugin.getDefault().getCombinedPreferenceStore().getBoolean(CEditor.SPACES_FOR_TABS); String indent; if (useSpaces) { int iSpaceIndent = CUIPlugin.getDefault().getCombinedPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); StringBuffer mystringbuf = new StringBuffer(); for ( int i=fInitialIndentLevel * iSpaceIndent; i>0; i-- ) mystringbuf.append ( ' ' ); indent = mystringbuf.toString(); } else { indent = Strings.createIndentString(fInitialIndentLevel); } #############################################################################
Created attachment 36123 [details] Fix described below in patch format Adding a patch which implements the fix described below. Pse always try submit your suggestions in patch format.
Patch applied. Thank you.