문제

I am trying to get LINQ queries to autoformat nicely, but they are "outdenting" some queries, which looks ugly and confusing. How do I get LINQ queries to format appropriately?

Here's the offending formatting

Repro CSProj (this is VS 2013 but it also happens in 2012)

My autoformatting options are defaults : AutoFormatting Part 1 Part 2 Part 3 Part 4

도움이 되었습니까?

해결책

So, it appears out that Visual Studio will not autoformat LINQ queries, most of the time. There are a few occasions where it appears that VS autoformatting makes things worse, but you can avoid those by using these steps.

However, if you use the correct keypresses when building queries, you can have it manually format correctly, and Visual Studio will NOT reformat it.

I've automated this using a vsvim macro, but it will work with any environment.

Poorly Formatted LINQ

Poorly Formatted LINQ

Step 1: Pull the second line up

Step 1

Step 2: Type "Enter" at the correct element to reformat correctly

Step 2

Step 3: Repeat as necessary for remainder of the query

Step 3

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top