Home AMX User Forum NetLinx Studio

Tab stops

So I just ran into the tab stop problem, working on code together with another programmer who uses a different value for the tab stops (1 vs. my 8). I'm still not sure how it managed to do this, but Studio saved the resulting file with 8-space tabs for my existing code, and 1-space tabs for the new code, meaning the edited file had a mix of tab values and was unrecoverable except by editing by hand. That doesn't seem like it should even be possible, but anyway...

Emacs has a feature that lets you set the tab stops for a file in a specially-formatted comment at the top of the file, like:
/* -*- tab-width: 4 -*- */

Can we get a similar feature in Studio so it automatically sets your tab width to the value specified in the file when you open it?

Comments

  • DHawthorneDHawthorne Posts: 4,584
    Interesting. I've seen more of my share of code from others that wound up indented right off the side of the page (nothing quite like looking at a blank page of code because the indents are too big), and I just assumed they were using a smaller value for tab than I was and made up for it by using multiples. I can't imagine how you got it mixed .. unless the other editor didn't really use tabs, but substituted spaces for them.
  • jweatherjweather Posts: 320
    Like I said, my tabs were set to 8, his were set to 1.

    When I saved the original file, every run of 8 spaces was converted to a tab. So far so good.

    When he opened the file, it displayed the existing tabs as single spaces -- not the end of the world, although it made the indentation a little odd.

    He added some lines, spacing the same as mine.

    When he saved the file, though, it left the existing lines with the same number of tabs, but added a tab for every run of 1 spaces in his new lines. So when I opened it again, my lines still looked normal, but his were indented off the right side of the page.

    If it had converted everything, it would have been recoverable. If it had used the existing size, it would have been recoverable. Since it mixed the two tab widths, it had to be edited back by hand to fix.
  • ericmedleyericmedley Posts: 4,177
    I've had the last two builds of NS2 blow out all my tabs. I'm one of those people who like outline indenting rather than standard java looking indentation.
    Button_Event[]
    {
    push:
      {
      // some code here
      }
    release:
      {
      // some code
      }
    }
    

    When NS takes out the indentaitons it can be real hard to read my code. That bad thing was NS2.6 still wouldn't save the ones I fixed. When I reopened the project, they were right back to being bad.

    I've been pleased with NS3beta, however. It seems to do Tabs quite well.
  • a_riot42a_riot42 Posts: 1,624
    You shouldn't use tabs for programming, only spaces. Normally, most programming editors have a 'use spaces instead of tabs' feature for just this purpose. Its silly that NS2 doesn't have this feature as it results in problems when viewing code written by someone else as you have noticed. I think I will write a Perl script that takes tabs and converts them to the amount of spaces required for this purpose.
    Paul
  • jjamesjjames Posts: 2,908
    And this is why I would like a code beautifier built into the next netlinx studio. I'll probably wind up making one of my own anyway before AMX gets to it.
  • ericmedleyericmedley Posts: 4,177
    a_riot42 wrote: »
    You shouldn't use tabs for programming, only spaces. Normally, most programming editors have a 'use spaces instead of tabs' feature for just this purpose. Its silly that NS2 doesn't have this feature as it results in problems when viewing code written by someone else as you have noticed. I think I will write a Perl script that takes tabs and converts them to the amount of spaces required for this purpose.
    Paul

    I was under the assumption that thjis is what it was doing... (just adding X spaces when you hit the tab key.) That's kind of the thing you'd assume when you go into the settings page and tell it how many spaces to tab... alas and anon...
  • JeffJeff Posts: 374
    ericmedley wrote: »
    I was under the assumption that thjis is what it was doing... (just adding X spaces when you hit the tab key.) That's kind of the thing you'd assume when you go into the settings page and tell it how many spaces to tab... alas and anon...

    That is what NS2 SHOULD do, but it's not what it actually does. It actually puts in a tab, which isn't a collection of spaces. If it put in a bunch of spaces, we wouldn't have these problems.

    J
  • bcirrisibcirrisi Posts: 148
    I agree with jjames, NS should automatically craft the code for you. Adobe developments do it (Flash/Action Script) and it's awesome. I find that I can program much faster with an auto code craft crafter, no need for tabbing, the enter button, or spacing at all. As you type the editors positions code for you. Plus it make it much easier reading other peoples code.
  • jjamesjjames Posts: 2,908
    I was actually referring to something along the lines like this:

    PrettyPrint
    http://en.wikipedia.org/wiki/Prettyprint

    Code Beautifier / Formatter Overview
    http://www.smashingmagazine.com/2007/07/12/time-savers-code-beautifier-and-formatter/


    I remember coming across a program where you could put in your own Syntax and all that and create a language, but forget the name of it.
  • So besides editing by hand, is there some sort of a shortcut anyone can recommend to make stuff line up properly?

    --John
Sign In or Register to comment.