facebook twitter hatena line email

「VisualStudioCode/設定/editorconfig」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(editorconfig設定方法)
 
(同じ利用者による、間の5版が非表示)
行1: 行1:
==editroconfig設定方法==
+
==editorconfig設定方法==
プロジェクト直下に.editorconfigファイルを置く
+
#拡張機能のeditorconfig https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig を入れる
 +
#[[VisualStudioCode/設定/omnisharp]] [ショートカット] のomnisharp.jsonの以下をtrueにする
 +
"EnableEditorConfigSupport": false,
 +
#プロジェクト直下に.editorconfigファイルを置く
  
 
 
行24: 行27:
 
# C# コードフォーマット設定
 
# C# コードフォーマット設定
 
csharp_indent_case_contents = true              # switch の case 内をインデント
 
csharp_indent_case_contents = true              # switch の case 内をインデント
csharp_indent_braces = true                     # `{}` をインデント
+
csharp_indent_braces = false                     # `{}` をインデント
 
csharp_new_line_before_else = true              # `else` の前に改行
 
csharp_new_line_before_else = true              # `else` の前に改行
 
csharp_new_line_before_catch = true              # `catch` の前に改行
 
csharp_new_line_before_catch = true              # `catch` の前に改行
行40: 行43:
  
 
参考:https://www.neputa-note.net/2020/10/vscode-editorconfig/
 
参考:https://www.neputa-note.net/2020/10/vscode-editorconfig/
 +
 +
参考:https://tanabebe.hatenablog.com/entry/2021/04/20/191500

2025年3月2日 (日) 01:06時点における最新版

editorconfig設定方法

  1. 拡張機能のeditorconfig https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig を入れる
  2. VisualStudioCode/設定/omnisharp [ショートカット] のomnisharp.jsonの以下をtrueにする
"EnableEditorConfigSupport": false,
  1. プロジェクト直下に.editorconfigファイルを置く

# .editorconfig のルート設定
root = true

# すべてのファイルに適用
[*]
indent_style = space        # インデントをスペースにする(tabs にするとタブ)
indent_size = 4             # インデント幅(タブの場合は `tab_width = 4`)
end_of_line = lf            # 改行コード(lf / crlf / cr)
charset = utf-8             # 文字エンコーディング
trim_trailing_whitespace = true  # 行末の空白を削除
insert_final_newline = true      # ファイルの最後に改行を追加

# C#(.cs)の設定
[*.cs]
indent_style = space
indent_size = 4
dotnet_diagnostic.IDE0055.severity = suggestion  # コードフォーマットの警告を提案レベルにする

# C# コードフォーマット設定
csharp_indent_case_contents = true               # switch の case 内をインデント
csharp_indent_braces = false                      # `{}` をインデント
csharp_new_line_before_else = true               # `else` の前に改行
csharp_new_line_before_catch = true              # `catch` の前に改行
csharp_new_line_before_finally = true            # `finally` の前に改行
csharp_space_after_keywords_in_control_flow_statements = true  # if や for の後にスペース
csharp_space_before_open_square_brackets = false # `array[index]` の `[` の前にスペースを入れない
csharp_space_within_square_brackets = false      # `array[ index ]` のような空白を入れない

# JSON ファイルの設定
[*.json]
indent_style = space
indent_size = 2  # JSON は一般的にスペース 2 が推奨


参考:https://www.neputa-note.net/2020/10/vscode-editorconfig/

参考:https://tanabebe.hatenablog.com/entry/2021/04/20/191500