Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The output is consistent if your tab settings are always the same when you look at your code, and you use the same tab size across all languages.

I view code in multiple ways, have different indentations for different languages (not many different now), and have clients that enforce difference indentation settings. It just doesn't work.



> The output is consistent if your tab settings are always the same when you look at your code, and you use the same tab size across all languages.

I don't really understand what you're getting at here to be honest, surely if you change your tab settings it's because you want the code to look different?

> I view code in multiple ways, have different indentations for different languages (not many different now),

This is exactly what tabs are great for! You can set the tab width based on language without having to force that choice on anyone else.

> clients that enforce difference indentation settings

Again, formatter.


I'm not sure if you're being deliberately obtuse, or just never look at files in only one way. I don't have that luxury.

Say I have a project that has Java and Rhino (JavaScript) files. My IDE/editor is configured for Java with TAB==4, JavaScript TAB==2. Everything looks great in my editor, because it knows things.

Now I'm using `less` or `cat` in my shell. Or ssh-ing to a remote box because of an emergency production issue. Or whatever. Now when I look at the file things no longer line up as originally intended, because when I view them outside of the (relatively) smarter IDE the TAB characters are at the mercy of whatever I am using to view the file.

You cannot simply rely on local tab width settings if files use a mix of tabs and spaces for indentation and alignment: if you change the tab width then alignment breaks. If you never align anything, great, tabs work great for indentation (except for when you can't trivially change it, then they suck). But indentation isn't the only thing tabs are used for.

There's the rub: TAB characters will always be at the mercy of how I'm viewing the file, which I do not always have control over, and certainly not (trivially) based on the type of the file.


> You cannot simply rely on local tab width settings if files use a mix of tabs and spaces for indentation and alignment: if you change the tab width then alignment breaks.

Ah I think you've misunderstood what I meant by tabs for indentation and space for alignment (something which you will be controlling with a formatter because that's the entire premise of my original comment). I'm not sure how to make it more clear, so I'll give you an example.

  class SomeClass {
  [tab]functions some_method(with, arguments) {
  [tab][tab]return a_function_call(with,
  [tab][tab]                       lots,
  [tab][tab]                       and,
  [tab][tab]                       lots,
  [tab][tab]                       of,
  [tab][tab]                       arguments);
  [tab]}
  }
Is that clearer?


Yup! Now view that across multiple languages, viewers, and tab sizes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: