JAVA开发经验(一):Eclipse使用1.2-格式化模板(Formatter)配置详解及保存自动格式化

摘要说明:

        一个项目往往都是多人开发,开发提交svn时若多人格式化的模板不一致,往往会不好比对;这里面一个项目组就需要统一格式化模板;

       本篇文章主要说明如何配置格式化模板及配置文件保存自动格式化;

1.添加方式

配置路径为:Window-->Preferences-->Java-->Code Style-->Formatter;

导入下面模版(如TIT_format.xml)后点击Apply保存配置即可:

模版中的名称即name可随意配置:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="11">
<profile kind="CodeFormatterProfile" name="TIT" version="11">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
</profile>
</profiles>

2.配置详解

上述配置中org.eclipse.jdt.core.formatter开头的配置详解:

comment.insert_new_line_before_root_tags(insert/do_not_insert):在Javadoc根标记块前插入空行,默认为insert;
insert_space_after_comma_in_annotation(insert/do_not_insert):在注释中的逗号后面插入空格,默认为insert;
insert_space_before_comma_in_type_parameters(insert/do_not_insert):用于在类型参数中在逗号前插入空格,默认为do_not_insert;
insert_space_before_opening_brace_in_type_declaration(insert/do_not_insert):用于在类型声明中打开括号之前插入空格,默认为insert;
insert_space_after_comma_in_type_arguments(insert/do_not_insert):用于在类型参数的逗号后面插入空格,默认为insert;
brace_position_for_anonymous_type_declaration(END_OF_LINE, NEXT_LINE, next_line_shift, NEXT_LINE_ON_WRAP):用于定位匿名类型声明的大括号,默认值:END_OF_LINE;
insert_space_before_colon_in_case(insert/do_not_insert):在冒号之前插入一个空格,在case语句中,默认为insert;
insert_space_after_opening_brace_in_array_initializer(insert/do_not_insert):用于在数组初始化器的开始括号之后插入空格,默认为do_not_insert;insert_new_line_in_empty_annotation_declaration(insert/do_not_insert):在空注释声明,默认为insert;insert_new_line_before_closing_brace_in_array_initializer(insert/do_not_insert):在数组初始化器的关闭括号之前插入新行,默认值:DO_NOT_INSERT;
insert_space_after_opening_paren_in_annotation(insert/do_not_insert):在注释中打开括号后插入空格,默认值:DO_NOT_INSERT;
blank_lines_before_field(其中n为零或正整数):用于在字段声明之前添加空行,默认为:0;insert_space_after_opening_paren_in_while(insert/do_not_insert):在一个while语句后面插入一个空格,默认值:DO_NOT_INSERT;insert_space_between_empty_parens_in_annotation_type_member_declaration(insert/do_not_insert):用于在注释类型成员声明中的空括号之间插入空格,默认值:DO_NOT_INSERT;
insert_new_line_before_else_in_if_statement(insert/do_not_insert):用于在if语句中的else关键字之前插入新行,默认值:DO_NOT_INSERT;
insert_space_after_prefix_operator(insert/do_not_insert):在前缀运算符之后插入空格的格式化,默认值:DO_NOT_INSERT;
keep_else_statement_on_same_line(TRUE, FALSE):以在同一行上保留else语句,默认为false;
insert_space_after_ellipsis(insert/do_not_insert):在省略之后插入一个空格,默认为insert;
comment.insert_new_line_for_parameter(insert/do_not_insert):在Javadoc根标记参数之后插入新行,默认为insert;
insert_space_before_opening_brace_in_annotation_type_declaration(insert/do_not_insert):在注释类型声明的开始括号之前插入空格,默认为insert;
indent_breaks_compare_to_cases(TRUE, FALSE):与cases相比,可以选择缩进中断,默认为true;
insert_space_after_at_in_annotation(insert/do_not_insert):在注释后面插入空格,默认为insert;
alignment_for_multiple_fields:用于对多个字段进行对齐,可能的值:由createAlignmentValue(boolean, int, int)调用返回的值——默认值:createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT);
alignment_for_expressions_in_array_initializer:用于数组初始化器中表达式对齐的格式化,可能的值:由createAlignmentValue(boolean, int, int)调用返回的值,默认:createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
alignment_for_conditional_expression:条件表达式对齐的格式化;insert_space_before_opening_paren_in_for(insert/do_not_insert):用于在for语句的圆括号前插入一个空格,默认为insert;
insert_space_after_binary_operator(insert/do_not_insert):在二进制操作符之后插入空格,默认为insert;
insert_space_before_question_in_wildcard(insert/do_not_insert):在通配符中问号前插入空格,默认值:DO_NOT_INSERT;
brace_position_for_array_initializer(END_OF_LINE, NEXT_LINE, next_line_shift, NEXT_LINE_ON_WRAP):用于定位数组初始化程序的大括号,默认值:END_OF_LINE;
insert_space_between_empty_parens_in_enum_constant(insert/do_not_insert):用于在enum常量的空括号之间插入空格,默认值:DO_NOT_INSERT;
insert_new_line_before_finally_in_try_statement(insert/do_not_insert):用于在try语句中的finally关键字之前插入新行,默认值:DO_NOT_INSERT;insert_new_line_after_annotation_on_local_variable(insert/do_not_insert):在本地变量注释后插入新行,默认:INSERT;
insert_new_line_before_catch_in_try_statement(insert/do_not_insert):在try语句,在catch关键字之前插入新行,默认值:DO_NOT_INSERT;
insert_space_before_opening_paren_in_while(insert/do_not_insert):用于在while语句中打开括号之前插入空格,默认为insert;
blank_lines_after_package(其中n为0或为正整数):用于在包声明之后添加空行,默认值:“0”;
insert_space_after_comma_in_type_parameters(insert/do_not_insert):在类型参数中,在逗号之后插入空格,默认为insert;
continuation_indentation(其中n为零或正整数):设置延续缩进,默认值:“2”;
insert_space_after_postfix_operator(insert/do_not_insert):在后缀操作符之后插入空格的,默认值:DO_NOT_INSERT;
alignment_for_arguments_in_method_invocation:用于方法调用中参数对齐的;
insert_space_before_closing_angle_bracket_in_type_arguments(insert/do_not_insert):在类型参数的关闭角括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_comma_in_superinterfaces(insert/do_not_insert):在类型头中的超接口名称中插入逗号前的空格,默认值:DO_NOT_INSERT;
blank_lines_before_new_chunk(其中n为零或正整数):用于在新块之前添加空行,默认值:“0;
blank_lines_before_package(其中n为零或正整数):在包声明之前添加空行,默认值:“0;
insert_space_after_comma_in_enum_constant_arguments(insert/do_not_insert):用于在enum常量,在逗号之后插入空格,默认为insert;
insert_space_after_opening_paren_in_constructor_declaration(insert/do_not_insert):构造函数声明中插入空格,默认:DO_NOT_INSERT;
insert_space_after_closing_angle_bracket_in_type_arguments(insert/do_not_insert):在类型参数的结束角括号之后插入空格,默认为insert;
comment.format_line_comments(TRUE, FALSE):控制单行注释是否格式化,默认为TRUE;
insert_space_after_comma_in_enum_declarations(insert/do_not_insert):在enum声明中,在逗号后插入空格,默认值:INSERT;
insert_space_before_opening_brace_in_block(insert/do_not_insert):用于在块中打开括号之前插入空格,默认值:INSERT;
alignment_for_arguments_in_explicit_constructor_call:用于显式构造函数调用中的参数对齐;
insert_space_before_comma_in_method_invocation_arguments(insert/do_not_insert):在方法调用的参数中,在逗号之前插入空格,默认:DO_NOT_INSERT;
blank_lines_before_member_type(其中n为零或正整数):用于在成员类型声明之前添加空行,默认值:“0;
align_type_members_on_columns(TRUE, FALSE):在列上对齐类型声明的类型成员,默认为false;
insert_space_after_opening_paren_in_enum_constant(insert/do_not_insert):在enum常量中打开括号之后插入空格,默认值:DO_NOT_INSERT;
insert_space_after_opening_paren_in_for(insert/do_not_insert):在for语句中插入空格后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_brace_in_method_declaration(insert/do_not_insert):用于在方法声明中的打开括号之前插入空格,默认值:INSERT;
alignment_for_selector_in_method_invocation:方法调用中选择器对齐;
insert_space_after_opening_paren_in_switch(insert/do_not_insert):用于在switch语句中打开括号后插入空格,默认值:DO_NOT_INSERT;
insert_space_after_unary_operator(insert/do_not_insert):在一个一元操作符后面插入空格,默认值:DO_NOT_INSERT;
insert_space_after_colon_in_case(insert/do_not_insert):用于在case语句中,当冒号后插入空格,默认值:INSERT;
indent_parameter_description(TRUE, FALSE):用于控制Javadoc参数的描述是否缩进,默认为TRUE;
insert_space_before_closing_paren_in_method_declaration(insert/do_not_insert):在方法声明中的结束括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_closing_paren_in_switch(insert/do_not_insert):在switch语句中关闭括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_brace_in_enum_declaration(insert/do_not_insert):在enum声明的开始括号之前插入空格,默认值:INSERT;
insert_space_before_opening_angle_bracket_in_type_parameters(insert/do_not_insert):在类型参数前插入空格,默认值:DO_NOT_INSERT;
insert_new_line_in_empty_type_declaration(insert/do_not_insert):在空类型声明中插入新行,默认值:INSERT;
comment.clear_blank_lines_in_block_comment(TRUE, FALSE):用于控制块注释中的空行是否被清除,默认为FLASE;
insert_space_before_opening_paren_in_if(insert/do_not_insert):用于在if语句中打开括号之前插入空格,默认值:INSERT;
insert_space_between_brackets_in_array_type_reference(insert/do_not_insert):用于在数组类型引用的括号中插入空格,默认值:DO_NOT_INSERT;
insert_space_after_opening_paren_in_parenthesized_expression(insert/do_not_insert):用于在圆括号中展开括号之后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_comma_in_explicitconstructorcall_arguments(insert/do_not_insert):在显式构造函数调用的参数中插入逗号前的空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_brace_in_constructor_declaration(insert/do_not_insert):在构造函数声明的开始括号之前插入空格,默认值:INSERT;
blank_lines_before_first_class_body_declaration(n为0或正整数):在第一个类body声明之前添加空行,-默认值:"0";
indentation.size(其中n为0或正整数):指定表示一个缩进的等效空格数,只有当选项卡char设置为混合时才使用此选项,默认值:“4”;
insert_space_between_empty_parens_in_method_declaration(insert/do_not_insert):用于在方法声明中的空括号之间插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_paren_in_enum_constant(insert/do_not_insert):在enum常量中打开括号之前插入空格,默认值:DO_NOT_INSERT;
alignment_for_superclass_in_type_declaration:用于在类型声明中对超类进行对齐;
alignment_for_assignment:分配对齐;
tabulation.char(TAB,空格,混合):指定表格大小,默认为TAB;
insert_space_after_comma_in_constructor_declaration_parameters(insert/do_not_insert):用于在构造函数声明的参数中插入逗号后的空格,默认值:INSERT;
insert_space_before_prefix_operator(insert/do_not_insert):用于在前缀操作符之前插入空格,默认值:DO_NOT_INSERT;
indent_statements_compare_to_body(TRUE, FALSE):在方法或构造函数的主体内缩进语句的,默认为TRUE;
blank_lines_before_method(其中n为零或正整数):用于在方法声明之前添加空行,默认值:“0”
format_guardian_clause_on_one_line(TRUE, FALSE):在一个行中保留保护条款,默认为FLASE;
insert_space_before_colon_in_for(insert/do_not_insert):用于在for语句的冒号之前插入空格,默认值:INSERT;
insert_space_before_closing_paren_in_cast(insert/do_not_insert):在转换表达式中关闭括号之前插入空格,默认值:DO_NOT_INSERT;
alignment_for_parameters_in_constructor_declaration:构造函数声明中参数对齐;
insert_space_after_colon_in_labeled_statement(insert/do_not_insert):在冒号后插入一个标记语句中的空格,默认值:INSERT;
brace_position_for_annotation_type_declaration(END_OF_LINE, NEXT_LINE, next_line_moved, NEXT_LINE_ON_WRAP):用于定位注释类型声明的大括号,默认值:END_OF_LINE;
insert_space_before_closing_paren_in_method_invocation(insert/do_not_insert):在方法调用的结束括号之前插入一个空格,默认值:DO_NOT_INSERT;
insert_new_line_in_empty_method_body(insert/do_not_insert):在空方法体中插入新行,默认值:INSERT;
insert_space_after_opening_bracket_in_array_allocation_expression(insert/do_not_insert):在数组分配表达式的左括号后面插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_brace_in_enum_constant(insert/do_not_insert):在enum中,在开环前插入一个空格,默认值:INSERT;
insert_space_before_comma_in_annotation(insert/do_not_insert):用于在注释中逗号前插入空格,默认值:DO_NOT_INSERT;
insert_space_after_at_in_annotation_type_declaration(insert/do_not_insert):用于在注释类型声明之后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_comma_in_method_declaration_throws(insert/do_not_insert):在方法声明的throw子句的异常名称中,在逗号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_closing_paren_in_if(insert/do_not_insert):在if语句的结束括号之前插入空格,默认值:DO_NOT_INSERT;
brace_position_for_switch(END_OF_LINE, NEXT_LINE, next_line_shift, NEXT_LINE_ON_WRAP):定位switch语句的大括号,默认为END_OF_LINE;
insert_space_after_comma_in_method_declaration_throws(insert/do_not_insert):在方法声明的抛出子句的异常名称中,在逗号之后插入空格,默认值:INSERT;
insert_space_before_parenthesized_expression_in_return(insert/do_not_insert):在返回语句中的括号表达式之前插入空格,默认值:INSERT;
insert_space_before_opening_paren_in_annotation(insert/do_not_insert):用于在注释中打开括号之前插入空格,默认值:INSERT;
insert_space_after_question_in_conditional(insert/do_not_insert):在条件表达式的问号后面插入空格,默认值:DO_NOT_INSERT;
insert_space_after_question_in_wildcard(insert/do_not_insert):在通配符中问号后面插入空格,默认值:DO_NOT_INSERT;
insert_space_before_closing_bracket_in_array_allocation_expression(insert/do_not_insert):在数组分配表达式中插入一个空格,默认值:DO_NOT_INSERT;
insert_space_before_parenthesized_expression_in_throw(insert/do_not_insert):在抛出语句中插入括号表达式之前的空格,默认值:INSERT;
insert_space_before_comma_in_type_arguments(insert/do_not_insert):用于在类型参数中在逗号之前插入空格,默认值:DO_NOT_INSERT;
indent_switchstatements_compare_to_switch(TRUE, FALSE):以缩进switch语句比较切换,默认为TRUE;
insert_space_before_ellipsis(insert/do_not_insert):在省略号之前插入空格,默认值:DO_NOT_INSERT;
brace_position_for_block(END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP):定位块的括号,默认为END_OF_LINE;
insert_space_before_comma_in_for_inits(insert/do_not_insert):用于在for语句的初始化中,在逗号之前插入空格,默认值:DO_NOT_INSERT;
brace_position_for_method_declaration( END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP):用于定位方法声明的大括号,默认为END_OF_LINE;
compact_else_if(TRUE, FALSE):压缩else/if,默认为TRUE;
insert_space_before_comma_in_array_initializer(insert/do_not_insert):在逗号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_after_comma_in_for_increments(insert/do_not_insert):在for语句的增量中,在逗号后面插入空格,默认值:INSERT;
insert_space_before_closing_bracket_in_array_reference(insert/do_not_insert):用于在数组引用的结束括号前插入空格,默认值:DO_NOT_INSERT;
brace_position_for_enum_constant(END_OF_LINE, NEXT_LINE, next_line_shift, NEXT_LINE_ON_WRAP):用于定位枚举常量的括号,默认为END_OF_LINE;
comment.indent_root_tags(TRUE, FALSE):控制Javadoc根标签是否缩进,默认为TRUE;
insert_space_before_comma_in_enum_declarations(insert/do_not_insert):在枚举声明中插入逗号前的空格,默认值:DO_NOT_INSERT;
insert_space_after_comma_in_explicitconstructorcall_arguments(insert/do_not_insert):用于在显式构造函数调用的参数中,在逗号之后插入空格,默认值:INSERT;
insert_space_before_opening_brace_in_switch(insert/do_not_insert):用于在开关语句的开始括号前插入空格,默认值:INSERT;
insert_space_after_comma_in_superinterfaces(insert/do_not_insert):在类型头的超接口名称中,在逗号之后插入空格,默认值:INSERT;
insert_space_before_comma_in_method_declaration_parameters(insert/do_not_insert):在方法声明的参数中,在逗号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_comma_in_allocation_expression(insert/do_not_insert):在分配表达式中插入一个空格,默认值:DO_NOT_INSERT;
tabulation.size(其中n为0或为正整数):指定表示一个表格的等效空格数,默认值:“4;
insert_space_before_opening_bracket_in_array_type_reference(insert/do_not_insert):用于在数组类型引用的左括号前插入空格,默认值:DO_NOT_INSERT;
insert_new_line_after_opening_brace_in_array_initializer(insert/do_not_insert):用于在数组初始化器的开始括号之后插入新行,默认值:DO_NOT_INSERT;
insert_space_after_closing_brace_in_block(insert/do_not_insert):在块的闭括号之后插入空格,默认值:INSERT;
insert_space_before_opening_bracket_in_array_reference(insert/do_not_insert):在数组引用的左括号之前插入空格,默认值:DO_NOT_INSERT;
insert_new_line_in_empty_enum_constant(insert/do_not_insert):在空enum常量中插入新行,默认值:INSERT;
insert_space_after_opening_angle_bracket_in_type_arguments(insert/do_not_insert):用于在类型参数的开始角括号之后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_paren_in_constructor_declaration(insert/do_not_insert):用于在构造函数声明中打开括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_after_opening_paren_in_if(insert/do_not_insert):在if语句中打开括号后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_comma_in_constructor_declaration_throws(insert/do_not_insert):在构造函数声明的throw子句的异常名称中,在逗号之前插入空格,默认值:DO_NOT_INSERT;
comment.clear_blank_lines_in_javadoc_comment(TRUE, FALSE):用于控制在javadoc注释中是否清除空行,默认为FALSE;
alignment_for_throws_clause_in_constructor_declaration:用于在构造函数声明中对齐抛出子句;
insert_space_after_assignment_operator(insert/do_not_insert):在赋值操作符之后插入空格,默认值:INSERT;
insert_space_before_assignment_operator(insert/do_not_insert):在赋值运算符之前插入空格,默认值:INSERT;
indent_empty_lines(TRUE, FALSE):缩进空行,默认为false;
insert_space_after_opening_paren_in_synchronized(insert/do_not_insert):在同步语句中打开括号后插入空格,默认值:DO_NOT_INSERT;
insert_space_after_closing_paren_in_cast(insert/do_not_insert):在转换表达式的结束括号之后插入空格,默认值:INSERT;
insert_space_after_comma_in_method_declaration_parameters(insert/do_not_insert):在方法声明的参数中插入逗号之后的空格,默认值:INSERT;
brace_position_for_block_in_case(END_OF_LINE、NEXT_LINE、next_line_shift、NEXT_LINE_ON_WRAP):当块是后面的第一个语句时,将块的大括号放在case语句中,默认值:END_OF_LINE;
number_of_empty_lines_to_preserve(其中n为0或正整数):指定要保存的空行数,默认值:"0";
insert_space_before_opening_paren_in_method_declaration(insert/do_not_insert):在方法声明中打开括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_after_opening_paren_in_catch(insert/do_not_insert):在catch中开括号后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_closing_paren_in_constructor_declaration(insert/do_not_insert):用于在构造函数声明中关闭括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_paren_in_method_invocation(insert/do_not_insert):在方法调用中打开括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_after_opening_bracket_in_array_reference(insert/do_not_insert):在数组引用的左括号后面插入空格,默认值:DO_NOT_INSERT;
insert_space_after_and_in_type_parameter(insert/do_not_insert):用于在wilcard后和中插入空格,默认值:INSERT;
alignment_for_arguments_in_qualified_allocation_expression:用于在限定分配表达式中对齐参数;
continuation_indentation_for_array_initializer(其中n为0或为正整数):用于设置数组初始化器中的延续缩进,默认值:“2”;
insert_space_between_empty_brackets_in_array_allocation_expression(insert/do_not_insert):在数组分配表达式的空括号之间插入空格,默认值:DO_NOT_INSERT;
insert_space_before_at_in_annotation_type_declaration(insert/do_not_insert):在注释类型声明之前插入空格,默认值:INSERT;
alignment_for_arguments_in_allocation_expression:用于在分配表达式中对齐参数;
insert_space_after_opening_paren_in_cast(insert/do_not_insert):在转换表达式中打开括号后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_unary_operator(insert/do_not_insert):在一元运算符之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_closing_angle_bracket_in_parameterized_type_reference(insert/do_not_insert):在参数化类型引用的结束角括号前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_brace_in_anonymous_type_declaration(insert/do_not_insert):用于在匿名类型声明中打开括号前插入空格,默认值:INSERT;
keep_empty_array_initializer_on_one_line(TRUE, FALSE):要保持空数组初始化器一行,默认值:FALSE;
insert_new_line_in_empty_enum_declaration(insert/do_not_insert):在空枚举声明中插入新行,默认值:INSERT;
keep_imple_if_on_one_line(TRUE, FALSE):用于在一行中保持简单的if语句,默认为FLASE;
insert_space_before_comma_in_constructor_declaration_parameters(insert/do_not_insert):用于在构造函数声明的参数中插入逗号前的空格,默认值:DO_NOT_INSERT;
insert_space_after_closing_angle_bracket_in_type_parameters(insert/do_not_insert):在类型参数的结束角括号之后插入空格,默认值:INSERT;
insert_new_line_at_end_of_file_if_missing(insert/do_not_insert):如果缺少的话,可以在当前文件的末尾插入新行,默认值:DO_NOT_INSERT;
insert_space_after_colon_in_for(insert/do_not_insert):在for语句中,在冒号后插入空格,默认值:INSERT;
insert_space_before_colon_in_labeled_statement(insert/do_not_insert):在冒号之前插入一个标记语句的空格,默认值:INSERT;
insert_space_before_comma_in_parameterized_type_reference(insert/do_not_insert):在参数化类型引用中在逗号之前插入空格,默认值:DO_NOT_INSERT;
alignment_for_superinterfaces_in_type_declaration:用于在类型声明中对超接口进行对齐;
alignment_for_binary_expression:用于二进制表达式的对齐brace_position_for_enum_declaration{END_OF_LINE, NEXT_LINE, next_line_shift, NEXT_LINE_ON_WRAP} :用于定位enum声明的大括号.默认值:END_OF_LINE;
insert_space_before_closing_paren_in_while(insert/do_not_insert):用于在while语句中结束括号之前插入空格,默认值:DO_NOT_INSERT;
put_empty_statement_on_new_line({TRUE, FALSE):用于指定空语句是否应该位于一个新的行,默认:FALSE;
insert_new_line_after_annotation_on_parameter(insert/do_not_insert):在参数的注释之后插入新行,默认值:DO_NOT_INSERT;
insert_space_after_opening_angle_bracket_in_type_parameters(insert/do_not_insert):
在类型参数中,在开始角括号之后插入空格,默认值:DO_NOT_INSERT;
insert_space_between_empty_parens_in_method_invocation(insert/do_not_insert):在方法调用的空括号之间插入空格,默认值:DO_NOT_INSERT;
insert_new_line_before_while_in_do_statement(insert/do_not_insert):在do语句之前插入新行,默认值:DO_NOT_INSERT;
alignment_for_arguments_in_enum_constant:为了在enum常量中对齐参数。
comment.format_javadoc_comments(TRUE, FALSE):用于控制javadoc注释是否被格式化,默认为TRUE;
comment.line_length(其中n为0或为正整数):指定注释的行长度,默认值:“80”;
blank_lines_between_import_groups(其中n为0或为正整数):添加导入组之间的空行,默认值:“1”;
insert_space_before_comma_in_enum_constant_arguments(insert/do_not_insert):在enum常量的参数中,在逗号前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_semicolon(insert/do_not_insert):在分号前插入空格,默认值:DO_NOT_INSERT;
brace_position_for_constructor_declaration  { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }:用于定位构造函数声明的大括号,默认值:END_OF_LINE;
number_of_blank_lines_at_beginning_of_method_body(其中n为0或正整数):在方法主体的开头添加空行,默认值:“0”;
insert_space_before_colon_in_conditional(insert/do_not_insert):用于在条件表达式的冒号前插入空格,默认值:INSERT;
indent_body_declarations_compare_to_type_header(TRUE, FALSE):将缩进体声明与它的封闭类型heade进行比较,默认为TRUE;
insert_space_before_opening_paren_in_annotation_type_member_declaration(insert/do_not_insert):在注释类型成员声明中打开括号之前插入空格,默认值:DO_NOT_INSERT;
wrap_before_binary_operator(TRUE, FALSE):在二进制运算符之前包装,默认为TRUE;
indent_body_declarations_compare_to_enum_declaration_header(TRUE, FALSE):与所附的enum声明头相比,缩进正文声明,默认为TRUE;
blank_lines_between_type_declarations(其中n为0或为正整数):在类型声明之间添加空白行,默认值:“0”;
insert_space_before_closing_paren_in_synchronized(insert/do_not_insert):在同步语句的结束括号之前插入空格,默认值:DO_NOT_INSERT;
indent_statements_compare_to_block(TRUE, FALSE):在块内缩进语句,默认为TRUE;
alignment_for_superinterfaces_in_enum_declaration:用于枚举声明中的超接口对齐;
insert_space_before_question_in_conditional(insert/do_not_insert):在条件表达式的问号前插入空格,默认值:INSERT;
insert_space_before_comma_in_multiple_field_declarations(insert/do_not_insert):用于在多个字段声明中在逗号之前插入空格,默认值:DO_NOT_INSERT;
alignment_for_compact_if:对于紧凑型if的对齐;
insert_space_after_comma_in_for_inits(insert/do_not_insert):用于在for语句的初始化中,在逗号之后插入空格,默认值:INSERT;
indent_switchstatements_compare_to_cases(TRUE, FALSE):对缩进开关语句进行比较,默认为TRUE;
insert_space_after_comma_in_array_initializer(insert/do_not_insert):在数组初始化器中插入逗号之后的空格,默认值:INSERT;
insert_space_before_colon_in_default(insert/do_not_insert):用于在默认语句中冒号之前插入空格,默认值:INSERT;
insert_space_before_and_in_type_parameter(insert/do_not_insert):用于在通配符前面和里面插入空格,默认值:INSERT;
insert_space_between_empty_parens_in_constructor_declaration(insert/do_not_insert):在构造函数声明的空括号之间插入空格,默认值:DO_NOT_INSERT;
insert_space_after_colon_in_assert(insert/do_not_insert):用于在assert语句中冒号之后插入空格,默认值:INSERT;
blank_lines_before_imports(其中n为0或为正整数):在导入声明之前添加空行,默认值:“0”;
comment.format_html(TRUE, FALSE):控制HTML标签是否被格式化,默认为TRUE;
alignment_for_throws_clause_in_method_declaratio:用于方法声明中抛出子句的对齐;
insert_space_before_closing_angle_bracket_in_type_parameters(insert/do_not_insert):用于在类型参数中的结束角括号前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_bracket_in_array_allocation_expression(insert/do_not_insert):用于在数组分配表达式的左括号前插入空格,默认值:DO_NOT_INSERT;
insert_new_line_in_empty_anonymous_type_declaration(insert/do_not_insert):在空的匿名类型声明中插入新行,默认值:INSERT;
insert_space_after_colon_in_conditional(insert/do_not_insert):在条件表达式的冒号后面插入空格,默认值:INSERT;
insert_space_after_opening_angle_bracket_in_parameterized_type_reference(insert/do_not_insert):在参数化类型引用的开始角括号之后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_closing_paren_in_for(insert/do_not_insert):在for语句的结束括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_postfix_operator(insert/do_not_insert):在后缀操作符之前插入空格,默认值:DO_NOT_INSERT;
comment.format_source_code(TRUE, FALSE):用于控制代码片段是否在注释中格式化,默认为TRUE;
insert_space_before_opening_paren_in_synchronized(insert/do_not_insert):在同步语句中打开括号之前插入空格,默认值:INSERT;
insert_space_after_comma_in_allocation_expression(insert/do_not_insert):在分配表达式的逗号后面插入空格,默认值:INSERT;
insert_space_after_comma_in_constructor_declaration_throws(insert/do_not_insert):用于在构造函数声明的throw子句的异常名称后面插入一个空格,默认值:INSERT;
alignment_for_parameters_in_method_declaration:方法声明中参数的对齐;
insert_space_before_closing_brace_in_array_initializer(insert/do_not_insert):用于在数组初始化器的闭括号前插入空格,默认值:DO_NOT_INSERT;
use_tabs_only_for_leading_indentations(TRUE, FALSE):用于对缩进和空格进行行包装,默认为FALSE;
insert_new_line_after_annotation_on_member(insert/do_not_insert):在成员的注释(包、类、方法、字段声明)之后插入新行,默认值:INSERT;
comment.format_header(TRUE, FALSE):控制Java源文件的头注释是否被格式化,默认为FALSE;
comment.format_block_comments(TRUE, FALSE):用于控制多行注释是否被格式化,默认为TRUE;
insert_space_before_closing_paren_in_enum_constant(insert/do_not_insert):在enum常量中关闭括号之前插入空格,默认值:DO_NOT_INSERT;
alignment_for_enum_constants:对于枚举常数的对齐;
insert_new_line_in_empty_block(insert/do_not_insert):用于在空块中插入新行,默认值:INSERT;
indent_body_declarations_compare_to_annotation_declaration_header(TRUE, FALSE):将缩进主体声明与其所包含的注释声明头进行比较,默认为TRUE;
insert_space_before_closing_paren_in_parenthesized_expression(insert/do_not_insert):在圆括号中的圆括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_paren_in_parenthesized_expression(insert/do_not_insert):在括号内的括号前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_closing_paren_in_catch(insert/do_not_insert):用于在catch - Option id中关闭括号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_comma_in_multiple_local_declarations(insert/do_not_insert):用于在多个本地声明中在逗号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_before_opening_paren_in_switch(insert/do_not_insert):用于在switch语句中打开括号之前插入空格,默认值:INSERT;
insert_space_before_comma_in_for_increments(insert/do_not_insert):用于在for语句的增量中在逗号之前插入空格,默认值:DO_NOT_INSERT;
insert_space_after_opening_paren_in_method_invocation(insert/do_not_insert):在方法调用中打开括号后插入空格,默认值:DO_NOT_INSERT;
insert_space_before_colon_in_assert(insert/do_not_insert):在assert语句中在冒号之前插入空格,默认值:INSERT;
brace_position_for_type_declaration{ END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }:用于定位类型声明的大括号,默认值:END_OF_LINE
insert_space_before_opening_brace_in_array_initializer(insert/do_not_insert):在数组初始化器中插入一个空格前插入一个空格,默认值:DO_NOT_INSERT;
insert_space_between_empty_braces_in_array_initializer(insert/do_not_insert):在数组初始化器中插入空括号之间的空格,默认值:DO_NOT_INSERT;
insert_space_after_opening_paren_in_method_declaration(insert/do_not_insert):用于在方法声明中打开括号后插入空格,默认:DO_NOT_INSERT;
insert_space_before_semicolon_in_for(insert/do_not_insert):在for语句中分号前插入空格,默认:DO_NOT_INSERT;
insert_space_before_opening_paren_in_catch(insert/do_not_insert):在catch中打开括号之前插入空格,默认值:INSERT;
insert_space_before_opening_angle_bracket_in_parameterized_type_reference(insert/do_not_insert):用于在参数化类型引用的开始角括号前插入空格,默认:DO_NOT_INSERT;
insert_space_after_comma_in_multiple_field_declarations(insert/do_not_insert):在多个字段声明中,在逗号后插入空格,默认值:INSERT;
insert_space_before_closing_paren_in_annotation(insert/do_not_insert):在注释中的结束括号之前插入空格,默认:DO_NOT_INSERT;
insert_space_after_comma_in_parameterized_type_reference(insert/do_not_insert):在参数化类型引用中,在逗号之后插入空格,默认值:INSERT;
insert_space_after_comma_in_method_invocation_arguments(insert/do_not_insert):在方法调用的参数中,在逗号之后插入空格,默认值:INSERT;
blank_lines_after_imports(其中n为0或为正整数):在导入声明之后添加空行,默认值:"0";
insert_space_after_comma_in_multiple_local_declarations(insert/do_not_insert):在多个本地声明中插入逗号之后的空格,默认值:INSERT;
indent_body_declarations_compare_to_enum_constant_header(TRUE, FALSE):对于缩进体声明,与它的封闭枚举常量标题比较,默认为TRUE;
insert_space_after_semicolon_in_for(insert/do_not_insert):用于在for语句中在分号之后插入空格,默认值:INSERT;
never_indent_line_comments_on_first_column(TRUE, FALSE):缩进从第一列开始的行注释,默认为FALSE;
insert_space_before_opening_angle_bracket_in_type_arguments(insert/do_not_insert):用于在类型参数的开始角括号前插入空格,默认:DO_NOT_INSERT;
never_indent_block_comments_on_first_column(TRUE, FALSE):对从第一列开始的注释进行缩进,默认为FALSE;
keep_then_statement_on_same_line(TRUE, FALSE):将语句保持在同一直线上,默认为FALSE;

更多可查看eclipse官方文档:点击org.eclipse.jdt.core.formatter --》DefaultCodeFormatterConstants进入;

3.配置保存自动格式化

上述配Window-->Preferences-->Java-->Editor-->Save Actions;其中有每次全部格式化(Format all lines)还是只格式化编辑部分(Format edited lines);

 

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: 您可以使用各种工具来自动格式化代码。对于 XML 文件,您可以使用 xmllint 工具来格式化。对于 nginx 配置文件,您可以使用 nginx -t 命令来检查配置文件的语法,并且 nginx 还提供了一个 ngx_conf_formatter 工具来格式化配置文件。对于 Java 代码,您可以使用 Eclipse 等 IDE 自带的代码格式化功能或者使用 Google Java Formatter 插件。对于 C 语言代码,您可以使用 indent 工具来格式化。 ### 回答2: 根据给定的内容自动完成格式化可以有多种方式,以下以XML格式化为例进行回答。 XML是一种标记语言,用于描述和储存数据,并且具有一定的结构。在进行XML格式化时,可以使用现有的XML解析库来实现。 首先,需要加载XML文件并解析文件内容。可以使用Java中的DOM或SAX解析器,也可以使用C语言中的libxml库进行解析。 一旦解析XML文件,就可以对文件内容进行格式化。一种常见的格式化方法是使用缩进,以提高可读性。我们可以递归地遍历XML文件的每个节点,并根据节点的层次关系使用不同层级的缩进。在Java中,可以使用递归函数来实现这一点,在C语言中可以使用循环结构来完成。 另一种格式化方法是添加换行符和空格。在遍历XML文件的过程中,可以在每个元素节点的开头和结尾添加换行符,并在元素节点的属性之间添加空格。这样可以使得XML文件中的元素节点更加清晰可辨。 最后,可以将格式化后的XML内容保存到新的文件中,或者直接输出到控制台供查看。 综上所述,根据给定的XML内容,可以使用相应的XML解析库(如Java的DOM或SAX、C语言的libxml)进行解析,并通过缩进、换行和空格等方式对XML文件进行格式化处理,以提高可读性。 ### 回答3: 自动完成格式化是指通过编程的方式将给定的内容按照特定的规则和格式进行整理和调整。根据不同的文件类型,可以使用不同的工具和技术来实现自动格式化。 对于XML格式的内容,可以使用XML解析库来读取和修改XML文件的结构和内容。通过解析XML文件,可以将其转化为内存中的树形结构,然后再将其按照规定的缩进、换行等格式重新输出到文件中,从而实现XML的自动格式化。 对于nginx配置文件的格式化,可以使用nginx内置的配置检查工具来实现。nginx提供了一个命令行工具"nginx -t",可以检查配置文件的语法正确性,并将配置文件输出到标准输出。可以将此输出重定向到一个暂存文件中,然后对该文件进行格式化操作,如去除多余空白行、添加缩进等,最后再将格式化后的文件覆盖原有的配置文件。 对于Java和C语言等编程语言,一般可以使用相关的IDE(集成开发环境)来实现代码的自动格式化。IDE提供了各种格式化选项,可以按照用户的喜好进行配置。通过IDE的格式化功能,可以对代码进行自动的缩进、换行、对齐等操作,使代码更加整洁易读。 总结来说,自动完成格式化是将给定的内容按照特定的格式整理调整的过程。根据不同的文件类型和编程语言,可以使用不同的工具和技术来实现自动格式化操作。无论是XML、nginx配置文件还是Java、C语言等,都能够通过合适的方式实现自动格式化

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值