NO

Author Topic: 'tabs to spaces' action should replace only leading spaces  (Read 3178 times)

Romashka

  • Guest
Currently 'Convert to -> Tabs (from spaces)' replaces every X spaces with a tab, but IMO it is reasonable to do this only for leading spaces.
The reason is that if someone loads your spaces-to-tabs converted source into his/her editor that has a different 'spaces in tab' number set - the identation changes would be fine, but in-text identation will be corrupted.
Suppose we have this code:
Code: [Select]
#include "header.h"         /* some comment*/
#include "another_header.h" /* some comment*/
#include <stdlib.h>         /* some comment */

if (abc) {
    foo = bar;
}
Here's what happens if user set 4 spaces in tab, converted spaces to tabs and loaded the converted file with 8 spaces in tab setting:
Code: [Select]
#include "header.h"                 /* some comment*/
#include "another_header.h" /* some comment*/
#include <stdlib.h>                 /* some comment */

if (abc) {
        foo = bar;
}

If 'Convert to -> Tabs (from spaces)' would convert only leading spaces - such corruption could be avoided.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: 'tabs to spaces' action should replace only leading spaces
« Reply #1 on: May 02, 2009, 05:05:56 PM »
I don't really care either way since I don't think tabs should be used in source files (at all). I can only say two things 1) it may be (slightly) easier to understand/explain the current behavior, and 2) since it has worked this way for a while now, I'm 110% sure someone will complain loudly about the change.
/Pelle