IntelliJ IDEA常用設置及快捷鍵


1. IntelliJ IDEA常用設置

1.1 Maven配置

  選擇菜單:Configure -> Settings -> Build,Execution,Deployment -> Build Tools -> Maven

  設置:【Maven home directory】

     【User settings file】

1.2 代碼提示與補充:不區分大小寫

  選擇菜單:Configure -> Settings -> Editor -> General -> Code Completion

  設置:

    【Case sensitive completion】:None   (不區分大小寫)

1.3 取消never used提示

  選擇菜單:Configure -> Settings -> Editor -> Inspections -> Declaration redundancy

  設置:

    【Unused declaration】取消勾選

1.4 取消拼寫檢查

  選擇菜單:Configure -> Settings -> Editor -> Inspections -> Spelling

  設置:

    【Spelling】取消勾選

1.5 修改自動提示快捷鍵

  IntelliJ IDEA默認自動提示快捷鍵為:Ctrl + Space,與中文輸入法切換快捷鍵沖突,修改IntelliJ IDEA自動提示快捷鍵步驟:

  選擇菜單:Configure -> Settings -> Keymap -> Main menu –> Code –> Completion

  設置:

    【Cycle Expand Word】移除快捷鍵

    【Basic】 設置快捷鍵 Alt + /

1.6 顯示行號及方法分隔線

  選擇菜單:Configure -> Settings -> Editor -> General -> Appearence

  設置:

    【Show line numbers】 勾選

    【Show method seperators】 勾選

 

1.7 設置項目默認sdk

  選擇菜單:Configure -> Project Defaults -> Project Structure

  設置:【Project SDK】

1.8 運行時配置(Runner)

  選擇菜單:Configure -> Project Defaults -> Settings

  設置:

    【VM Options】:-DarchetypeCatalog=internal

    注:archetypeCatalog的3種值

      internal:maven-archetype-plugin內置

      local:本地,位置為~/.m2/archetype-catalog.xml

      remote:指向Maven中央倉庫的Catalog

1.9 文件編碼格式

1.10 關閉提示Found Duplicate Code

  選擇菜單:Configure -> Settings -> Editor -> Inspections

  設置:

    【Duplicated Code】:取消勾選

1.11 配置自定義瀏覽器預覽

  選擇菜單:File -> Settings -> Tools -> Web Browsers

  

  

1.12 spring-boot-devtools熱部署

  (1)pom.xml配置

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>true</fork>
            </configuration>
        </plugin>
    </plugins>
</build>

  (2)IDEA設置

  ◊ 選擇菜單:Configure -> Settings -> Build,Execution,Deplyment -> Compiler

  設置:

    【Build project automatically】:勾選

  ◊ 組合鍵 Ctrl + Shift + Alt + / ,選擇【Registry...】,勾選【compiler.automake.allow.when.app.running】

2. 項目設置

2.1 配置項目文件夾

  選擇菜單:File -> Project Structure... (Ctrl + Shift + Alt + S) -> Modules

3. IntelliJ IDEA常用快捷鍵

3.1 基礎功能

快捷鍵 功能
Ctrl + Space 基本代碼提示
Ctrl + Shift + Space 按類型信息提示
Alt + Enter 快速自動修復錯誤代碼
Ctrl + Shift + Enter 自動補全末尾的字符,包括行尾的反括號和分號
Ctrl + Y 刪除當前行
Ctrl + D 復制當前行並插入在下面一行
Ctrl + / 注釋 //
Ctrl + Shift + / 注釋 /*...*/
Ctrl + Shift + U 大小寫轉化
Ctrl + Alt + L 格式化代碼
Ctrl + Alt + O 優化import列表

3.2 查找替換

快捷鍵 功能
Ctrl + F 當前窗口中進行文本查找
Ctrl + Shift + F 全工程中進行文本查找
Ctrl + R 當前窗口中進行文本替換
Ctrl + Shift + R 全工程中進行文本替換

3.3 代碼生成

快捷鍵 功能
Alt + Insert 自動生成構造函數、toString()、getter/setter、重寫父類方法等
fori + Tab for循環
sout + Tab System.out.println語句
psvm + Tab main方法

4. IntelliJ IDEA的Git操作

4.1 Git設置

  選擇菜單:Configure -> Settings -> Version Control -> Git

  設置:

    【Path to Git executable】:設置Git的安裝路徑

4.2 發布新項目到Git

  步驟:

  (1)選擇菜單:VCS -> Import into Version Control -> Create Git Repository...

  (2)選擇創建Git倉儲路徑,選擇之后將在該路徑下創建.git隱藏文件夾。

  (3)選擇菜單:VCS -> Git -> Commit Directory...

  (4)選擇菜單:VCS -> Git -> Push


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM