program tip

Visual Studio 2005/2012 : 첫 번째 중괄호를 같은 줄에 유지하는 방법?

radiobox 2020. 7. 30. 10:17
반응형

Visual Studio 2005/2012 : 첫 번째 중괄호를 같은 줄에 유지하는 방법?


내 CSS / C # 함수를 다음과 같이 얻으려고합니다.

body {
    color:#222;
}

이 대신에 :

body 
{
    color:#222;
}

코드를 자동 형식화하면


씨#

  1. 에서 도구 메뉴를 클릭 옵션
  2. 모든 매개 변수 표시 (왼쪽 하단의 확인란)를 클릭 합니다 ( VS 2010의 모든 설정 표시 )
  3. 텍스트 에디터
  4. 씨#
  5. 서식
  6. 새로운 줄

괄호가있는 줄 바꿈을 원할 때 확인하십시오.

CSS :

거의 동일하지만 더 적은 옵션

  1. 에서 도구 메뉴를 클릭 옵션
  2. 모든 매개 변수 표시 (왼쪽 하단의 확인란)를 클릭 합니다 ( VS 2010의 모든 설정 표시 )
  3. 텍스트 에디터
  4. CSS
  5. 체재

원하는 형식을 선택하는 것보다 (두 번째 라디오 버튼)

Visual Studio 2015의 경우 :

도구 → 옵션

사이드 바에서 텍스트 편집기 → C # → 형식 → 줄 바꿈으로 이동하십시오.

"중괄호의 새 줄 옵션" 섹션에서 모든 확인란의 선택을 취소하십시오.

여기에 이미지 설명을 입력하십시오


Tools -> Options -> Text Editor -> C# -> Formatting -> New Lines -> New Line Options for braces -> Uncheck all boxes.


The official MS guidelines (at the time in 2008) tells you to have the curly brace on the same line as the method/property/class and many other things which are not enforced in Visual Studio.

You can change all these auto-text settings under:
Tools -> Options -> Text Editor -> [The language you want to change]

UPDATE: This was based on the book "Framework Design Guidelines" written by some of the core-people from the .NET-team. If you look at the source-code for the likes of ASP.NET MVC, this is no longer accurate.


Go to Tools -> Options -> Text Editor -> CSS -> Formatting. Click "Semi-expanded," which matches the style you defined.

옵션 화면


For CSS you'll need the 'Semi Expanded' option.


There is a specific formatting setting in VS 2008/2010 to keep the open brace on the same line:

Click Tools->Options
Select 'CSS' within 'Text Editor' tree node
Select 'Formatting' under 'CSS' node
Click 'Semi-expanded' radio button

You will see a preview what the various radio buttons avail will do to the formatting


If you're looking for this option within Visual Studio 2014, then it's under advanced and is now a 'Brace positions' drop down box:

여기에 이미지 설명을 입력하십시오

참고 URL : https://stackoverflow.com/questions/39561/visual-studio-2005-2012-how-to-keep-first-curly-brace-on-same-line

반응형