Code formatting

@dsfog@dsfog Posts: 4 Bronze 2
edited December 31, 2012 6:50AM in SQL Prompt Previous Versions
I have noticed som mishaps when auto formatting my code, where perfectly sane TSQL is going off.

Most simple example I have found:
Write
DROP TABLE
With caret placed exactly after TABLE press Ctrl + Enter.
Line is now
DROTABLELE

Same mishaps are at times found for ASC and DESC keywords, but I have not identified a way to consistently reproduce these errors (nor tried to).


Setup
SSMS 2012
SQL Prompt 5.3.6.28
Connection Coloring as only experimental feature[/code]

Exported Style XML:
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<!---->
<LayoutOptions version="1" type="LayoutOptions">
<ReservedWordsCasing>1</ReservedWordsCasing>
<BuiltInFunctionCasing>1</BuiltInFunctionCasing>
<BuiltInDataTypeCasing>1</BuiltInDataTypeCasing>
<DelimitIdentifiers>False</DelimitIdentifiers>
<IndentationAmount>4</IndentationAmount>
<UseTabs>False</UseTabs>
<ReformatExpressions>True</ReformatExpressions>
<FirstColumnOnNewLine>False</FirstColumnOnNewLine>
<CommasAtStart>True</CommasAtStart>
<MultilineSpacesAfterCommas>True</MultilineSpacesAfterCommas>
<MultilineSpacesBeforeCommas>True</MultilineSpacesBeforeCommas>
<MultilineAlignCommasWithStatement>False</MultilineAlignCommasWithStatement>
<OperatorsOnNewline>True</OperatorsOnNewline>
<OperatorsAtStart>True</OperatorsAtStart>
<IndentBeginToken>True</IndentBeginToken>
<IndentWithExpressionBrackets>True</IndentWithExpressionBrackets>
<IndentWithParameterBrackets>True</IndentWithParameterBrackets>
<IndentWithQueryBrackets>True</IndentWithQueryBrackets>
<CloseBracketsOnNewLine>True</CloseBracketsOnNewLine>
<OpenBracketsOnNewLine>False</OpenBracketsOnNewLine>
<Wrap>True</Wrap>
<WrapWidth>78</WrapWidth>
<ShortLength>15</ShortLength>
<CreateBracketsAtStartOfLines>False</CreateBracketsAtStartOfLines>
<ParameterBracketOnNewline>True</ParameterBracketOnNewline>
<CloseParameterBracketsOnNewLine>True</CloseParameterBracketsOnNewLine>
<CompactShortStatements>False</CompactShortStatements>
<SinglelineSpacesAfterCommas>True</SinglelineSpacesAfterCommas>
<SinglelineSpacesBeforeCommas>False</SinglelineSpacesBeforeCommas>
<SpacesAroundOperators>True</SpacesAroundOperators>
<SpacesAroundComparisons>True</SpacesAroundComparisons>
<FirstParameterDefinitionOnNewLine>True</FirstParameterDefinitionOnNewLine>
<SpacesAfterBrackets>False</SpacesAfterBrackets>
<LayoutSelectStatements>True</LayoutSelectStatements>
<LayoutCreateStatements>True</LayoutCreateStatements>
<QueryNewlineAfterOpenBracket>False</QueryNewlineAfterOpenBracket>
<QueryNewlineBeforeCloseBracket>True</QueryNewlineBeforeCloseBracket>
<JoinConditionsOnNewline>True</JoinConditionsOnNewline>
<AlignConditionsWithJoins>False</AlignConditionsWithJoins>
<AlignJoinsWithFrom>True</AlignJoinsWithFrom>
<IndentByKeywordWidth>False</IndentByKeywordWidth>
<ColumnsOnSingleLine>False</ColumnsOnSingleLine>
<DoNotIndentProcedureContents>False</DoNotIndentProcedureContents>
<ExecuteParametersOnSingleLine>True</ExecuteParametersOnSingleLine>
<UseSpacesInsteadOfTabs>False</UseSpacesInsteadOfTabs>
<IndentSelectSubclauses>False</IndentSelectSubclauses>
</LayoutOptions>

Comments

  • Matt_BMatt_B Posts: 12 Bronze 2
    I've been noticing this same problem for some time now, the ASC and DESC keywords being frequently rewritten seemingly without my input.

    As per the OP, I can't find a certain way to consistently reproduce (although the Ctrl+Enter after DROP TABLE produces the same results), so was assuming it was keyboard clumsiness.
  • Glad I've seen this thread - I thought I was going mad!

    The example I had was 'select * from' then Ctrl+Enter, becomes 'select fromom'
  • Why are you using Ctrl + Enter ?? shouldn't you be using Ctrl + Space if you want to manually trigger suggestions?

    Drop Table Ctrl+space works fine, but I too get the problem with Ctrl+Enter with version 5.3.6.28 in SSMS 2008r2
Sign In or Register to comment.