天天看點

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

文章目錄

  • idea中的超實用小技巧提升編碼效率
    • 一、自定義代碼模闆
      • 1.1 Live Templates
      • 1.2 File Templates
    • 二、快捷變量
    • 三、maven快速搜尋
    • 四、Inject Language
    • 五、快速列編輯

idea中的超實用小技巧提升編碼效率

一、自定義代碼模闆

1.1 Live Templates

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

定義模闆:

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

使用:

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

1.2 File Templates

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

當我們在建立對應檔案的時候,就會按照檔案模闆來生成檔案内容。

二、快捷變量

### 2.1 Postfix Completion
           
idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率
public class PostfixCompletion {

    private static Student student;

    public static void main(String[] args) {

        Student student2 = new Student(); // new Student().var 建立局部變量
        student = new Student(); // new Student().filed 全局變量
        Student  student3 = (Student ) new Object();// new Student().castvar 強制轉換

        if (student == null) { // student.null 判斷空

        }
        if (student != null) { // student.nn  判斷非空

        }

        boolean flag = true;
        if (flag) { // flag.if

        }

        System.out.println(flag); // flag.sout 輸出
        System.out.println("flag = " + flag); // flag.soutv 輸出有變量辨別

        try {
            main(new String[]{}); // main.try 捕獲異常
        } catch (Exception e) {
            e.printStackTrace();
        }
 }
           
idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

使用:

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

三、maven快速搜尋

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率
idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

四、Inject Language

Inject Language 幫助我們快速編輯字元串:選擇編寫哪種格式的字元串

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率
idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

五、快速列編輯

選擇代碼的時候,按住 Alt 鍵 就可以選中 列 之後選中的代碼 可以 修改、複制、粘貼、删除

idea中的超實用小技巧提升編碼效率idea中的超實用小技巧提升編碼效率

複制某一行代碼快捷鍵:

将光标定位到需要複制的代碼那行: Ctrl + Alt + 方向鍵下 可以将一行代碼,向下複制。

繼續閱讀