Competition: What’s your favorite Redgate tool? Enter now.

indentation of BEGIN and END

jeljeljeljeljeljel Posts: 7
edited August 1, 2017 12:54PM in SQL Refactor Previous Versions
The indentation rules I have make the BEGIN and END statements indent.

So I get this ...
if (@a350 > 0) 
    begin
        set @installationCharges = 311
    end

I would like this instead ...
if (@a350 > 0) 
begin
    set @installationCharges = 311
end


Is there a way to make the refactor format for example #2?

Thanks,
John

Comments

  • Well I see the examples didn't format correctly. The first example had the BEGIN and END statements indented 4 spaces, then the code line indented 8 spaces.

    What I would like is for the BEGIN and END to line up with the IF keyword.
  • The forum indicates that the original message was created 11 May 2007, but the message states 10 May 2005?

    However, I'm with jeljeljel in this, I'd like my begin's to align with the IF statement in the line above.
    pcd
  • I would like to see this as well.
    This is how C# formats it's code as well.

    if (disposing && (components != null))
    {
    (4 spaces here) components.Dispose();
    }
  • I'll pile on to this one also.

    How about giving us the option between the following?

    A.
    if (@a350 > 0) 
        begin 
            set @installationCharges = 311 
        end 
    

    B.
    if (@a350 > 0) 
    begin 
        set @installationCharges = 311 
    end 
    

    C.
    if (@a350 > 0) begin 
        set @installationCharges = 311 
    end 
    

    I actually prefer C in many cases, but it would be nice to be able to specifiy.

    Regards,
  • By the way guys, use the BBCode CODE directive to format code properly.

    Visit this link to learn more.

    Regards,
  • I think it is strange that BEGIN/END block only indents as prior posts describe. I just started using the SQL Refactor 1.10, and is disappointed that for example WHILE statements always follows by an indented BEGIN/END block. This is probably unwanted for many users and makes the code less readable - and the extra TAB is completely unnecessary. However when the WHILE statement is followed by a single statement, there should be an indent.

    I would really like to see the following two:
    WHILE @@FETCH_STATUS = 0
    BEGIN
        SELECT 0
    END
    

    And why not a Symbian style for those into that:
    WHILE @@FETCH_STATUS = 0
        BEGIN
        SELECT 0
        END
    

    In short - please add the possibility both to select block indention as non-mandatory, and the level of indention on sub-blocks too. That would really improve the readability of the layout. Thanks
    Rikard Arhag
    Software Engineer, Tools Engineering
    UIQ Technologies AB, Sweden
Sign In or Register to comment.