VS2015 autoformat

Status
Not open for further replies.

foetusinc

Ars Scholae Palatinae
1,409
Subscriptor++
OK, I've gotta be missing an obvious option somewhere...

I always turn off a few of the editor formatting options, like auto bracket closure, but mostly use the defaults. Anyway, when I want to code a new property, I'll actually just type it out, only using autocomplete for the type name if it's something complex:

p-u-b-l-i-c- -s-t-r-i-n-g- -p-r-o-p-n-a-m-e-{-g-e-t-;-s-e-t-;-}
And then it autoformats on the closing brace so I end up with
Code:
public string propname { get; set; }

I know there are more "efficient" ways like the prop snippet, but my fingers are trained by thousands of repetitions to do it that way at this point. I can type {get;set;} like a boss all day long.

Now something has changed in 2015, because as soon as I type that first semicolon, it's adding a newline. Then when I close the block it autoformats and I end up with
Code:
public string propname
{
    get; set;
}

The horror! I played with the options under Formatting->Wrapping, but neither gets me what I want. It seems like they "fixed" the prettifier so it can format a statement even when the block it's in isn't closed/valid, which is a bummer given how I like it to work. Am I the only person who's noticed this? Am I insane for caring?
 

Ardax

Ars Legatus Legionis
19,795
Subscriptor
Here's the contents of my C# settings. Save them to a .vssettings file for import. (or check by eye if you want.)

Code:
<UserSettings>
	<ApplicationIdentity version="14.0" />
	<ToolsOptions>
		<ToolsOptionsCategory name="TextEditor" RegisteredName="TextEditor">
			<ToolsOptionsSubCategory name="CSharp-Specific" RegisteredName="CSharp-Specific" PackageName="CSharpPackage">
				<PropertyValue name="Style_UseVarWhenDeclaringLocals">1</PropertyValue>
				<PropertyValue name="Space_AroundBinaryOperator">1</PropertyValue>
				<PropertyValue name="NewLines_QueryExpression_EachClause">1</PropertyValue>
				<PropertyValue name="Formatting_TriggerOnPaste">1</PropertyValue>
				<PropertyValue name="ExtractMethod_DoNotPutOutOrRefOnStruct">1</PropertyValue>
				<PropertyValue name="Style_PreferIntrinsicPredefinedTypeKeywordInDeclaration">1</PropertyValue>
				<PropertyValue name="NewLines_Braces_Method">1</PropertyValue>
				<PropertyValue name="HighlightReferences">1</PropertyValue>
				<PropertyValue name="InsertNewlineOnEnterWithWholeWord">0</PropertyValue>
				<PropertyValue name="Indent_CaseLabels">1</PropertyValue>
				<PropertyValue name="Formatting_TriggerOnBlockCompletion">1</PropertyValue>
				<PropertyValue name="EnableHighlightRelatedKeywords">1</PropertyValue>
				<PropertyValue name="Space_WithinOtherParentheses">0</PropertyValue>
				<PropertyValue name="NewLines_Braces_ControlFlow">1</PropertyValue>
				<PropertyValue name="NewLines_Braces_AnonymousMethod">1</PropertyValue>
				<PropertyValue name="ExtractMethod_AllowMovingDeclaration">0</PropertyValue>
				<PropertyValue name="BringUpOnIdentifier">1</PropertyValue>
				<PropertyValue name="Wrapping_KeepStatementsOnSingleLine">1</PropertyValue>
				<PropertyValue name="Space_AfterBasesColon">1</PropertyValue>
				<PropertyValue name="Indent_Braces">0</PropertyValue>
				<PropertyValue name="DisplayLineSeparators">0</PropertyValue>
				<PropertyValue name="Wrapping_IgnoreSpacesAroundVariableDeclaration">0</PropertyValue>
				<PropertyValue name="WarnOnBuildErrors">1</PropertyValue>
				<PropertyValue name="Style_PreferIntrinsicPredefinedTypeKeywordInMemberAccess">1</PropertyValue>
				<PropertyValue name="Space_WithinMethodCallParentheses">0</PropertyValue>
				<PropertyValue name="Space_AfterCast">0</PropertyValue>
				<PropertyValue name="SortUsings_PlaceSystemFirst">1</PropertyValue>
				<PropertyValue name="ShowSnippets">1</PropertyValue>
				<PropertyValue name="ShowKeywords">1</PropertyValue>
				<PropertyValue name="Space_WithinExpressionParentheses">0</PropertyValue>
				<PropertyValue name="Space_InControlFlowConstruct">1</PropertyValue>
				<PropertyValue name="NewLines_Keywords_Catch">1</PropertyValue>
				<PropertyValue name="NewLines_Braces_ObjectInitializer">1</PropertyValue>
				<PropertyValue name="NewLines_AnonymousTypeInitializer_EachMember">1</PropertyValue>
				<PropertyValue name="Formatting_TriggerOnStatementCompletion">1</PropertyValue>
				<PropertyValue name="ClosedFileDiagnostics">1</PropertyValue>
				<PropertyValue name="Space_BetweenEmptyMethodDeclarationParentheses">0</PropertyValue>
				<PropertyValue name="NewLines_Keywords_Finally">1</PropertyValue>
				<PropertyValue name="Indent_UnindentLabels">2</PropertyValue>
				<PropertyValue name="NewLines_ObjectInitializer_EachMember">1</PropertyValue>
				<PropertyValue name="NewLines_Keywords_Else">1</PropertyValue>
				<PropertyValue name="Style_QualifyMemberAccessWithThisOrMe">0</PropertyValue>
				<PropertyValue name="Space_WithinMethodDeclarationParentheses">0</PropertyValue>
				<PropertyValue name="Space_BetweenEmptyMethodCallParentheses">0</PropertyValue>
				<PropertyValue name="Space_BeforeSemicolonsInForStatement">0</PropertyValue>
				<PropertyValue name="Space_BeforeComma">0</PropertyValue>
				<PropertyValue name="Space_AfterMethodCallName">0</PropertyValue>
				<PropertyValue name="Space_AfterComma">1</PropertyValue>
				<PropertyValue name="Wrapping_IgnoreSpacesAroundBinaryOperators">0</PropertyValue>
				<PropertyValue name="Space_BeforeBasesColon">1</PropertyValue>
				<PropertyValue name="Space_AfterMethodDeclarationName">0</PropertyValue>
				<PropertyValue name="Space_AfterDot">0</PropertyValue>
				<PropertyValue name="RenameTrackingPreview">1</PropertyValue>
				<PropertyValue name="AutoComment">1</PropertyValue>
				<PropertyValue name="NewLines_Braces_Type">1</PropertyValue>
				<PropertyValue name="EnterOutliningModeOnOpen">1</PropertyValue>
				<PropertyValue name="Space_WithinSquares">0</PropertyValue>
				<PropertyValue name="NewLines_Braces_LambdaExpressionBody">1</PropertyValue>
				<PropertyValue name="Space_WithinCastParentheses">0</PropertyValue>
				<PropertyValue name="Space_AfterSemicolonsInForStatement">1</PropertyValue>
				<PropertyValue name="NewLines_Braces_AnonymousTypeInitializer">1</PropertyValue>
				<PropertyValue name="Indent_FlushLabelsLeft">0</PropertyValue>
				<PropertyValue name="Indent_CaseContents">1</PropertyValue>
				<PropertyValue name="Wrapping_PreserveSingleLine">1</PropertyValue>
				<PropertyValue name="Space_BetweenEmptySquares">0</PropertyValue>
				<PropertyValue name="Space_BeforeOpenSquare">0</PropertyValue>
				<PropertyValue name="Space_BeforeDot">0</PropertyValue>
				<PropertyValue name="RenameSmartTagEnabled">1</PropertyValue>
				<PropertyValue name="Refactoring_Verification_Enabled">0</PropertyValue>
				<PropertyValue name="Indent_BlockContents">1</PropertyValue>
			</ToolsOptionsSubCategory>
		</ToolsOptionsCategory>
	</ToolsOptions>
</UserSettings>
 

foetusinc

Ars Scholae Palatinae
1,409
Subscriptor++
No other extensions - I use a pretty vanilla install. If I go back and remove all the extra newlines and then do a ctrl-K-D it does keep the correct formatting, it's just completing that get; while the block is incomplete that seems to throw it. No big settings differences that I see. I have statement completion turned off now as a workaround, and I have the option set to sort System usings, but that's it. How about your General settings (the Text Management section in the settings file)?

Code:
@@ -1,5 +1,5 @@
 <UserSettings>
-  <ApplicationIdentity version="14.0" />
+  <ApplicationIdentity version="14.0"/>
   <ToolsOptions>
     <ToolsOptionsCategory name="TextEditor" RegisteredName="TextEditor">
       <ToolsOptionsSubCategory name="CSharp-Specific" RegisteredName="CSharp-Specific" PackageName="CSharpPackage">
@@ -29,7 +29,7 @@
         <PropertyValue name="Style_PreferIntrinsicPredefinedTypeKeywordInMemberAccess">1</PropertyValue>
         <PropertyValue name="Space_WithinMethodCallParentheses">0</PropertyValue>
         <PropertyValue name="Space_AfterCast">0</PropertyValue>
-        <PropertyValue name="SortUsings_PlaceSystemFirst">1</PropertyValue>
+        <PropertyValue name="SortUsings_PlaceSystemFirst">0</PropertyValue>
         <PropertyValue name="ShowSnippets">1</PropertyValue>
         <PropertyValue name="ShowKeywords">1</PropertyValue>
         <PropertyValue name="Space_WithinExpressionParentheses">0</PropertyValue>
@@ -37,7 +37,7 @@
         <PropertyValue name="NewLines_Keywords_Catch">1</PropertyValue>
         <PropertyValue name="NewLines_Braces_ObjectInitializer">1</PropertyValue>
         <PropertyValue name="NewLines_AnonymousTypeInitializer_EachMember">1</PropertyValue>
-        <PropertyValue name="Formatting_TriggerOnStatementCompletion">1</PropertyValue>
+        <PropertyValue name="Formatting_TriggerOnStatementCompletion">0</PropertyValue>
         <PropertyValue name="ClosedFileDiagnostics">1</PropertyValue>
         <PropertyValue name="Space_BetweenEmptyMethodDeclarationParentheses">0</PropertyValue>
         <PropertyValue name="NewLines_Keywords_Finally">1</PropertyValue>
@@ -75,5 +75,32 @@
         <PropertyValue name="Indent_BlockContents">1</PropertyValue>
       </ToolsOptionsSubCategory>
     </ToolsOptionsCategory>
+    <ToolsOptionsSubCategory name="CSharp" RegisteredName="CSharp" PackageName="Text Management Package">
+      <PropertyValue name="TabSize">4</PropertyValue>
+      <PropertyValue name="ShowChanges">true</PropertyValue>
+      <PropertyValue name="AutoListMembers">true</PropertyValue>
+      <PropertyValue name="ShowPreview">true</PropertyValue>
+      <PropertyValue name="ShowMarks">true</PropertyValue>
+      <PropertyValue name="IndentStyle">2</PropertyValue>
+      <PropertyValue name="ShowCaretPosition">true</PropertyValue>
+      <PropertyValue name="HideAdvancedMembers">true</PropertyValue>
+      <PropertyValue name="ShowNavigationBar">true</PropertyValue>
+      <PropertyValue name="UseMapMode">false</PropertyValue>
+      <PropertyValue name="VirtualSpace">false</PropertyValue>
+      <PropertyValue name="ShowAnnotations">true</PropertyValue>
+      <PropertyValue name="ShowVerticalScrollBar">true</PropertyValue>
+      <PropertyValue name="InsertTabs">false</PropertyValue>
+      <PropertyValue name="WordWrapGlyphs">true</PropertyValue>
+      <PropertyValue name="EnableLeftClickForURLs">true</PropertyValue>
+      <PropertyValue name="ShowErrors">true</PropertyValue>
+      <PropertyValue name="OverviewWidth">58</PropertyValue>
+      <PropertyValue name="ShowLineNumbers">false</PropertyValue>
+      <PropertyValue name="WordWrap">false</PropertyValue>
+      <PropertyValue name="IndentSize">4</PropertyValue>
+      <PropertyValue name="BraceCompletion">false</PropertyValue>
+      <PropertyValue name="ShowHorizontalScrollBar">true</PropertyValue>
+      <PropertyValue name="CutCopyBlankLines">true</PropertyValue>
+      <PropertyValue name="AutoListParams">true</PropertyValue>
+    </ToolsOptionsSubCategory>
   </ToolsOptions>
 </UserSettings>
 

Ardax

Ars Legatus Legionis
19,795
Subscriptor
Weird. I'm not sure why you're running into this then.

Code:
<UserSettings>
	<ApplicationIdentity version="14.0" />
	<ToolsOptions>
		<ToolsOptionsCategory name="TextEditor" RegisteredName="TextEditor">
			<ToolsOptionsSubCategory name="AllLanguages" RegisteredName="AllLanguages" PackageName="Text Management Package" />
			<ToolsOptionsSubCategory name="General" RegisteredName="General" PackageName="Text Management Package">
				<PropertyValue name="DragNDropTextEditing">true</PropertyValue>
				<PropertyValue name="HighlightCurrentLine">true</PropertyValue>
				<PropertyValue name="EditorEmulation">0</PropertyValue>
				<PropertyValue name="DetectUTF8WithoutSignature">true</PropertyValue>
				<PropertyValue name="TrackChanges">true</PropertyValue>
				<PropertyValue name="UndoCaretActions">false</PropertyValue>
				<PropertyValue name="SelectionMargin">true</PropertyValue>
				<PropertyValue name="GoToAnchorAfterEscape">false</PropertyValue>
				<PropertyValue name="AutoDelimiterHighlighting">true</PropertyValue>
				<PropertyValue name="MarginIndicatorBar">true</PropertyValue>
			</ToolsOptionsSubCategory>
		</ToolsOptionsCategory>
	</ToolsOptions>
</UserSettings>
 
Status
Not open for further replies.