What is the best way to format source code examples? It seems that indentation is ruined when some user chooses to edit using ConvertSpacesToTabs. Currently, I use (1 + 4 * N) spaces for indentation (N is the level of indentation). I had even more problems with my usual (3 * N). Using Tabs+Space seems too deep and is cumbersome to do without a handy tool.
IndentationTestFunction4p1() { /* what I would like to have e.g. */ for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { if(i>j) { if(i+j>8) { /* */ } } } } } IndentationTestFunction4p1() { /* ruined */ for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { if(i>j) { if(i+j>8) { /* */ } } } } }IndentationTestFunction3() { /* ruined */
for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { if(i>j) { if(i+j>8) { /* */ } } } }}
IndentationTestFunctionTabsPure() {
for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { if(i>j) { if(i+j>8) { /* */ } } } }}
IndentationTestFunctionSpaceTabs() { for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { if(i>j) { if(i+j>8) { /* */ } } } } } IndentationTestFunctionTabsSpace() { for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { if(i>j) { if(i+j>8) { /* */ } } } } }
It would be nice to be able to use some trick, such as a prefix character (after initial space), to disable ConvertSpacesToTabs (i.e. spaces in preformatted lines should not be converted. I could see a standard being 1 or 2 spaces, followed by a line number, followed by whatever indentation you choose. Unfortunately, Wiki currently changes spaces on all lines.
Hear, hear!