Align aliases, commas, datatypes and expressions at the next tab stop
I align aliases, commas, datatypes and expressions at the first tab stop following the longest element in the list. See examples below:
-- Tilde character used as space replacement to cope with HTML formatting
-- 2-character tabs are assumed below
-- In a fixed-space font, the commas, = signs, data types and AS keywords would all line up vertically
DECLARE
~~@x~~~~~~~~~~~~~~INT~~~~~~~~~,
~~@var~~~~~~~~~~~~VARCHAR(4)~~,
~~@longer_varname~VARCHAR(10)~,
~~@z~~~~~~~~~~~~~~DATETIME~~~~;
SELECT
~~~~@longer_varname~=~'x'~~~~~~~,
~~~~@var~~~~~~~~~~~~=~'1234'~~~~,
~~~~@z~~~~~~~~~~~~~~=~GETDATE()~;
SELECT
~~~~T1.shortfield~~~~~~~~AS~ShortField~,
~~~~AO.reallylongfield~~AS~LongField~~,
~~~~'x'~~~~~~~~~~~~~~~~~~~AS~XChar~~~~~~,
~~FROM~~~~~~~~dbo.table1~~~~~~AS~T1
~~~~LEFT~JOIN~dbo.anotherone~AS~AO~ON~T1.keyval~=~AO.keyval;
EXEC~@x~=~dbo.SomeProc
~~@Param1~=~'3'~~~~~~~~~~~,
~~@P2~~~~~=~'Longer~Text'~,
~~@P3~~~~~=~4~~~~~~~~~~~~~;
-
Mark Palnau commented
Should just use tab characters, but otherwise I agree.
-
David Wright commented
I imagine this will be difficult to implement: perhaps the option could be given to obey the formatting options, but retain whitespace where it is currently compressed to one space?
-
AdminJustin Caldicott (Admin, Redgate) commented
Thank you for your feedback.