Jump to content
Sign in to follow this  
Richard Robertson

Spaces vs tabs

Recommended Posts

I'm sure most of you are familiar with this dinosaur aged discussion, but I was thinking about this earlier and it occurred to me that the only reasons it's even a discussion are in-line comments and line wrapping.

When you have code like

Dim $a = 4      ; a number
Dim $b = "test" ; a string

you might tab or space the comments to align them vertically.

When the front of the line is indented by a number of spaces, and the comment is padded with a number of spaces, it shows up the same on anyone's editor. When you use tabs before the line and spaces for padding, it shows up aligned again. But if you use tabs for padding, other users may see comments that are no longer aligned. This could also happen if tabs are used before the line and the lines are indentented unevenly (like an if header and the first line of the block).

The second part, line wrapping, is something I only rarely see. Observe this code.

Dim $c = [0, _
          1, _

This will also die if tab length changes.

Is anyone else aware of any other situations where spaces or tabs can cause problems? Tabs can be configured to fit the user's preference while spaces cannot and vertical alignment is awkward in tabs but not spaces.

Other thoughts: why don't we have an indent and dedent pair and an alignment character that will visually align text? Then you could use a single indent character at the start of a line if it should be pushed right, a single dedent if it should be pushed left, and a single align character padding for causing text to line up?

Edited by Richard Robertson

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...