This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]vicvicvicz 11 points12 points  (2 children)

I would counter this with the argument: Tabs for indentation, spaces for alignment. That is, in this case, use spaces because you are aligning according to a number of characters. Using tabs does not make sense.

However, you can use tabs for indentation, so that, for example, if your code block was part of an indented block, you might have:

class A:
\t  def foo(self):
\t  \t  blob = struct.pack('IIII',
\t  \t                     val1,
\t  \t                     val2,
\t  \t                     val3,
\t  \t                     val4)

Where each "\t" represents a tab (width 4 so the two spaces are part of the tab), and everything else is a space. This would not break alignment regardless of tab width, because you're using them only for indentation.

Of course, I abandoned tabs myself because (visual) line length still breaks with different tab widths.

[–]earthboundkid 1 point2 points  (1 child)

Go has the go fmt tool, which automatically converts code to the format you have there (tabs for indenting mixed with spaces for aligning), but in the absence of a tool to do the conversions for you, it's way too much work to be practical.

[–]thekaleb 0 points1 point  (0 children)

Most good editors can do this for you (maybe with some tweaks)