1. 程式人生 > >自用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>