Eclipse代码格式化设置简单介绍

时间:2019-04-07
本文章向大家介绍Eclipse代码格式化设置简单介绍,主要包括Eclipse代码格式化设置简单介绍使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

自用项目中统一Eclipse格式化Java、JavaScript、JSP、HTML代码设置

1.Window->Preferences 
//Java 格式化 
2.Java->Code Style->Formatter->New->Edit->Line Wrapping 
3.Maximum Line width = 180 
4.Set line width for preview window = 180 
//JavaScript 格式化 
5.JavaScript->Code Style->Formatter->New->Edit->Line Wrapping 
6.Maximum Line width = 180 
7.Set line width for preview window = 180 
8.Tab标签页->Comments 
9.Maximum line width for comments = 180 
//JSP|HTML页面 格式化 
10.Web->HTML Files->Editor 
Line width = 180 
Inline Elements 选中所有-> Remove 

格式化前:

<script> 
    $("#loginBtn") 
        .click( 
            function() { 
              $ 
                  .ajax({ 
                    url : "/Test/userInfo/login", 
                    type : 'POST', 
                    dataType : 'json', 
                    data : { 
                      userAccount : $("#userAccount") 
                          .val(), 
                      password : $("#password").val() 
                    }, 
                    success : function(data, textStatus, 
                        xhr) { 
 
                      window.location.href = "/Test/userInfo/userlogin"; 
                    }, 
                    error : function(xhr, textStatus, 
                        errorThrown) { 
                      //alert("登录异常请重新登录") 
                      $.messager.show({ 
                        title : '提示', 
                        msg : '登录异常请重新登录', 
                      }); 
 
                    }, 
                    complete : function() { 
                      // $yr.closeMask(); 
                    } 
                  }); 
 
            }); 
</script> 

格式化后:

<script> 
    $("#loginBtn").click(function() { 
      $.ajax({ 
        url : "/Test/userInfo/login", 
        type : 'POST', 
        dataType : 'json', 
        data : { 
          userAccount : $("#userAccount").val(), 
          password : $("#password").val() 
        }, 
        success : function(data, textStatus, xhr) { 
 
          window.location.href = "/Test/userInfo/userlogin"; 
        }, 
        error : function(xhr, textStatus, errorThrown) { 
          //alert("登录异常请重新登录") 
          $.messager.show({ 
            title : '提示', 
            msg : '登录异常请重新登录', 
          }); 
 
        }, 
        complete : function() { 
          // $yr.closeMask(); 
        } 
      }); 
 
    }); 
</script> 

总结

以上就是本文关于Eclipse代码格式化设置简单介绍的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:Java源码解析之TypeVariable详解Java探索之Hibernate主键生成策略详细介绍等,如有不足之处,欢迎留言参考。感谢朋友们对本站的支持!