Code formatting

Provides intelligent code completion for SQL Server editors.

Moderators: JonathanWatts, David Atkinson, Anu Deshpande, Paul Stephenson, Michelle Taylor, Mike Upton, justin.caldicott, Aaron Law

Code formatting

Postby @dsfog » Tue Dec 04, 2012 10:10 am

I have noticed som mishaps when auto formatting my code, where perfectly sane TSQL is going off.

Most simple example I have found:
Write
Code: Select all
DROP TABLE

With caret placed exactly after TABLE press Ctrl + Enter.
Line is now
Code: Select all
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>
@dsfog
 
Posts: 1
Joined: Tue Dec 04, 2012 9:40 am

Same here

Postby Matt_B » Wed Dec 05, 2012 10:26 am

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.
Matt_B
 
Posts: 9
Joined: Tue Feb 19, 2008 8:58 am

Postby kevriley » Fri Dec 21, 2012 4:32 pm

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'
kevriley
 
Posts: 70
Joined: Tue Apr 07, 2009 12:46 pm
Location: UK

Postby WeeeBob » Mon Dec 31, 2012 12:50 pm

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
WeeeBob
 
Posts: 12
Joined: Thu Jun 14, 2007 4:16 pm


Return to SQL Prompt 5

Who is online

Users browsing this forum: No registered users and 1 guest