Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right-aligned vs. left-aligned clause keywords #1

Open
rask opened this issue Feb 3, 2016 · 2 comments
Open

Right-aligned vs. left-aligned clause keywords #1

rask opened this issue Feb 3, 2016 · 2 comments

Comments

@rask
Copy link

rask commented Feb 3, 2016

Is there any particular reason for choosing

  SELECT *
    FROM table
   WHERE col1 = 'val'
ORDER BY col2

instead of

SELECT   *
FROM     table
WHERE    col1 = 'val'
ORDER BY col2

I'm not saying neither is better or worse, just wondering about what the pros and cons could be in both formatting styles.

@adjenks
Copy link

adjenks commented Feb 12, 2019

I like to use tabs to align things, which doesn't seem to work well with this alignment.

Even if I use spaces if I start with this:

SELECT *
  FROM table
 WHERE col1 = 'val'

then I decide to edit it and add a longer line I run into this trouble:

SELECT *
  FROM table
 WHERE col1 = 'val'
ORDER BY col2

The "single character column between the keywords and their objects", is now out of line, and I have to
go back and add a bunch of leading spaces.

Am I doing this wrong? Is there an easy way to align these?

Perhaps you need to set your text editor to use spaces, then select all of the previous lines and then indent them all at once. Anyhow, this is too much time effort for me and I have no trouble reading things out of line so I think I'm going to disagree with the right-aligned keywords. It does look good but I don't want to spend time aligning things using spaces to get columns to align, that just seems excessive to me.

@rask
Copy link
Author

rask commented Feb 13, 2019

Good point @adjenks, I have not seen any autoformatter in my editors/IDEs that would support this indentation style either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants