Author Topic: Tabs and spaces again  (Read 3914 times)

swarrier

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Tabs and spaces again
« on: November 03, 2010, 07:10:30 pm »
Hi
  I've just started using SlickEdit and there is a certain section of the project that has a coding style in C and C++ which is like this.
The indentation is always to be displayed as 4 spaces but in the files this is the way it works.
 On a line the first tab always indents four spaces. The next tab inserts a hard tab. The next tab inserts 4 spaces, the next tab inserts a hard tab.
Consequently the source files follow the following format..
 If I were to represent a space with an 's' and a hard tab with a 't'

Then the lines
    if (something) {
        i++;
    }
would look like this
ssssif (something)s{
ti++;
ssss}
Is it possible to set up SlickEdit to mirror this mode.
I'm not much in favour of this. I prefer all tabs or all spaces. This mix is a bother.

Thanks

S


hs2

  • Senior Community Member
  • Posts: 2752
  • Hero Points: 291
Re: Tabs and spaces again
« Reply #1 on: November 03, 2010, 07:23:16 pm »
This is new - and crazy.
But I think in principle this could be done by creating your own say 'crazy-tab' command and the appropriate key and mode bindings.
However, I wouldn't do that - I'd change or ignore the rules ;)

Good luck, HS2

swarrier

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Tabs and spaces again
« Reply #2 on: November 04, 2010, 01:59:52 pm »
Yes  it is rather painful...
   I think the not so brilliant idea was perhaps to save the pain of putting spaces all over .. so you could use spaces for the first indentation a hard tab for the next which would sort of simulate 8 spaces, a tab and 4 spaces for the next indent, 2 tabs for the indent after that and so on...
   Doesn't display well at all especially in diffs etc..

Thanks

S

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Tabs and spaces again
« Reply #3 on: November 05, 2010, 01:26:39 am »
This sounds like the style where tab width is 8, and syntax indent (aka shift width) is 4.  The style has been around a long time, and its principle benefit seems to be that it satifies those who like tabs (such as myself) but also ensures that indentations are represented accurately when printing the code (or diffs!) to the console.

A few projects I work in use this style, and SE seems to support it fine, in fact Adaptive Formatting even correctly and reliably recognizes this style, at least in the ~1500 files I have that use this style.

You should be able to force it with the following settings:
Syntax Indent = 4
Tabs = +8
Indent with tabs = YES