Turn off 'Smart' Tabs in Dev++

If you try using Dev-C++ (which I cannot recommend all that highly; it's okay but it's by no means great) you may find that you get some very odd behavior when trying to indent code. Suppose you have a snippet like this:

if(error != 0) {
FSClose(file_id);
oops_error(207);
return;
}

The natural thing to do is indent it neatly by inserting another tab1 before each of the three inner lines. Unfortunately, you may wind up with something that looks like this:

if(error != 0) {
         FSClose(file_id);
         oops_error(207);
         return;
}

You have just become a victim of the 'Smart Tabs' feature, whose tooltip description states

on tab cursor is moved to first nonblank space of preceeding[sic] line

What this description glosses over is that this feature seems to try to work by inserting tabs and spaces so that the indented material will be aligned with the first non-whitespace character following the next whitespace chaacter, by column of the preceding line. In the example above, the lines to be indented were already at the level of the leading whitespace from the preceding line, so the 'Smart Tabs' feature went looking until it found some more whitespace, namely the space before the comparison operator. This means that unless your lines of code never include internal whitespace, you indentation will come out looking really odd. Solution: From the Dev-C++ 'Tools' menu, select 'Editor Options' and in the 'General' tab, uncheck 'Smart Tabs'. You'll have to press the tab key a little more often, but sanity will now reign throughout the code:

if(error != 0) {
    FSClose(file_id);
    oops_error(207);
    return;
}

  1. We cannot overemphasize this point: Tab characters are for indenting! Indenting is accomplished by means of tab characters! 

No Comments

Comment on this post