EditorConfig ファイルを使用したコード スタイル設定の共有

EditorConfig ファイルを使用すると、カスタムのエディター設定をさまざまな環境で共有できます。EditorConfig ファイルがプロジェクトまたはファイル システムに存在する場合、その設定が Visual Studio のグローバルなコード スタイル設定よりも常に優先されます。新しいコードを記述すると、それらの設定に従って自動的にフォーマットされます。このファイルの設定と連携するコマンドは次のとおりです。

このファイルを組織内のチーム間で共有して、デフォルトのコード スタイル設定を設定したり、特定のプロジェクトにのみ適用したりできます。これにより、すべての開発者が一貫したコード スタイルを使用できるようになります。

Visual Studio のオプションを使用した EditorConfig ファイルの作成

  1. [Tools > Options > Text Editor > Micro Focus COBOL > Code Style > Code Cleanup] をクリックします。
  2. [Generate .editorconfig file from settings] をクリックします。
  3. ファイルを保存するマシン上のフォルダーに移動し、[Save] をクリックします。

ソリューションまたはプロジェクトの EditorConfig ファイルの作成

  • ソリューション エクスプローラーでソリューションを右クリックし、[Add > New EditorConfig (COBOL)] をクリックします。

    プロジェクトまたはフォルダー レベルでファイルを作成する場合は、コマンドは [Add > New EditorConfig] になります。

ファイル システムに複数の EditorConfig ファイルがある場合のルール

システムに EditorConfig ファイルが複数存在する場合があります。ファイルに root = true 設定が含まれている場合、それが Visual Studio で使用する最上位のファイルであることを示します。

Visual Studio では、最初に、エディターで開いているソース ファイルを含むフォルダーで .editorconfig を検索します。その後、最上位のフォルダーに到達するか、root = true を含む .editorconfig が見つかるまで、親ディレクトリを順番に検索していきます。

Visual Studio では、最初に root = true を含む .editorconfig ファイルの設定を適用してから、ディレクトリ ツリーの下位の子フォルダーで見つかった .editorconfig ファイルの設定を適用します。

EditorConfig ファイルの詳細については、「関連情報」にあるリンクを参照してください。

.editorconfig ファイルの例

.editorconfig の例を次に示します。これは、特定の環境の Visual Studio で指定されたいくつかのコード スタイル設定とその値を示しています。

# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true

# COBOL Files
[*.{cbl,ccp,cob,cobol,cpb,cpf,cpv,cpy,eco,if,ins,mf,pco,prc,sqb,v1}]

#### Core EditorConfig Options ####

indent_size = 4
indent_style = space
tab_width = 4

#### COBOL Options ####

# General preferences
mf_cobol_base_indent = 0
mf_cobol_preserve_left_margin = true
mf_cobol_wrap_column = 30
mf_cobol_right_margin_strategy = slide
mf_cobol_directive_alignment = indicator
mf_cobol_align_inline_comments = true
mf_cobol_preserve_end_of_line_comments = false

# Procedure Division preferences
mf_cobol_continuation_indent = 0
mf_cobol_nested_indent_reference = continuation_indent
mf_cobol_entry_point_column = 0
mf_cobol_full_stop_alignment = 17
mf_cobol_if_continuation_indent = unset
mf_cobol_if_condition_per_line = false
mf_cobol_if_condition_operator_alignment = false
mf_cobol_evaluate_indent = 4
mf_cobol_evaluate_when_indent = 5
mf_cobol_format_statements = true
mf_cobol_to_keyword_alignment = none
mf_cobol_align_using_parameters = false
mf_cobol_argument_alignment = by_continuation_indent

# Identification Division preferences
mf_cobol_break_after_heading = false

# Environment Division preferences
mf_cobol_ensure_new_line_after_paragraph_in_configuration_section = false

# Data Division preferences
mf_cobol_data_base_indent = 0
mf_cobol_data_indent = 12
mf_cobol_data_name_indent = 0
mf_cobol_data_name_top_indent = 0
mf_cobol_data_relation = parent_level_number
mf_cobol_data_clause_alignment = none

# Code cleanup preferences
mf_cobol_operator_style = unset
mf_cobol_qualifier_style = unset
mf_cobol_then_keyword_style = unset
mf_cobol_usage_keyword_style = unset
mf_cobol_id_keyword_style = id
mf_cobol_pic_keyword_style = unset
mf_cobol_comp_keyword_style = unset
mf_cobol_binary_keyword_style = unset