IntelliJ IDEAbasicoperation

LearningIntelliJ IDEA basicoperation, includingcreationproject, configurationSDK, basic编辑operation, file and file夹managementetc.

1. creation and 打开project

in IntelliJ IDEAin, creation and 打开project is 最basic operation之一. IntelliJ IDEAsupport many 种projectclass型, includingJava, Kotlin, Scala, JavaScriptetc..

1.1 creation new project

要creation一个 new project, 请按照以 under 步骤operation:

  1. 启动IntelliJ IDEA
  2. in 欢迎界面, 点击"New Project"
  3. 选择projectclass型, such as"Java"
  4. 选择projectSDK (such as果尚未configuration, 点击"Add SDK"添加)
  5. 点击"Next"
  6. 选择 is 否creationGit仓library (可选)
  7. 点击"Next"
  8. 输入project名称 and 位置
  9. 点击"Finish"

1.2 打开现 has project

要打开一个现 has project, 请按照以 under 步骤operation:

  1. 启动IntelliJ IDEA
  2. in 欢迎界面, 点击"Open"
  3. 浏览 to projectwhereTable of Contents, 选择projectfile夹
  4. 点击"OK"

1.3 from version控制systemcloneproject

要 from Git, SVNetc.version控制systemcloneproject, 请按照以 under 步骤operation:

  1. 启动IntelliJ IDEA
  2. in 欢迎界面, 点击"Get from VCS"
  3. 选择version控制systemclass型, such as"Git"
  4. 输入仓libraryURL and 本地store位置
  5. 点击"Clone"

2. configurationSDK

SDK (Software Development Kit) is Software Developmenttoolpackage, package含了Developmentspecificlanguage or framework所需 tool, library and run时environment. in IntelliJ IDEAin, 你需要 for 每个projectconfiguration相应 SDK.

2.1 添加SDK

要添加SDK, 请按照以 under 步骤operation:

  1. 点击File > Project Structure
  2. in left 侧面板in, 选择"SDKs"
  3. 点击"+"按钮, 选择SDKclass型, such as"JDK"
  4. 浏览 to SDKinstallationTable of Contents, 点击"OK"
  5. 点击"Apply" and "OK"保存设置

2.2 for projectconfigurationSDK

要 for projectconfigurationSDK, 请按照以 under 步骤operation:

  1. 点击File > Project Structure
  2. in left 侧面板in, 选择"Project"
  3. in "Project SDK" under 拉菜单in, 选择要using SDK
  4. in "Project language level" under 拉菜单in, 选择project language级别
  5. 点击"Apply" and "OK"保存设置

提示

你可以 for 不同 moduleconfiguration不同 SDK and language级别, 以满足 complex project requirements.

3. basic编辑operation

IntelliJ IDEAproviding了丰富 编辑functions, helping你更 high 效地writingcode.

3.1 code补全

IntelliJ IDEA code补全functions非常强 big , 可以根据 on under 文智能推荐code. 常用 code补全 fast 捷键including:

  • Ctrl + 空格: basiccode补全
  • Ctrl + Shift + 空格: 智能code补全 (根据 on under 文)
  • Ctrl + Alt + 空格: class名补全
  • Ctrl + Shift + Enter: 自动补全codestructure (such as括号, 分号etc.)

3.2 codeformat

要formatcode, 请using以 under fast 捷键:

  • Ctrl + Alt + L: format当 before file
  • Ctrl + Alt + Shift + L: formatcode设置

3.3 codefold

要fold or unfoldcode块, 请using以 under fast 捷键:

  • Ctrl + -: fold当 before code块
  • Ctrl + +: unfold当 before code块
  • Ctrl + Shift + -: fold所 has code块
  • Ctrl + Shift + +: unfold所 has code块

3.4 find and replace

要find and replace文本, 请using以 under fast 捷键:

  • Ctrl + F: in 当 before fileinfind
  • Ctrl + R: in 当 before fileinreplace
  • Ctrl + Shift + F: in 整个projectinfind
  • Ctrl + Shift + R: in 整个projectinreplace

3.5 many 行编辑

IntelliJ IDEAsupport many 行编辑functions, 可以同时编辑 many 个位置 文本. 要using many 行编辑, 请按住Alt键并点击要编辑 位置, or 者usingAlt + Shift + 鼠标拖动选择 many 行.

4. file and file夹management

in IntelliJ IDEAin, 你可以throughprojecttool窗口easilymanagementfile and file夹.

4.1 creationfile and file夹

要creationfile or file夹, 请按照以 under 步骤operation:

  1. in projecttool窗口in, right 键点击要creationfile or file夹 父Table of Contents
  2. 选择"New"
  3. 选择要creation file or file夹class型, such as"Java Class", "Directory"etc.
  4. 输入名称, 点击"OK"

4.2 renamefile and file夹

要renamefile or file夹, 请按照以 under 步骤operation:

  1. in projecttool窗口in, right 键点击要rename file or file夹
  2. 选择"Refactor" > "Rename"
  3. 输入 new 名称, 点击"Refactor"

4.3 move and copyfile

要move or copyfile, 请按照以 under 步骤operation:

  1. in projecttool窗口in, right 键点击要move or copy file
  2. 选择"Refactor" > "Move" or "Copy"
  3. 选择目标位置, 点击"Refactor" or "OK"

4.4 deletefile and file夹

要deletefile or file夹, 请按照以 under 步骤operation:

  1. in projecttool窗口in, right 键点击要delete file or file夹
  2. 选择"Delete"
  3. in 确认 for 话框in, 点击"OK"

5. run and debug

IntelliJ IDEAproviding了强 big run and debugfunctions, 可以helping你test and debugcode.

5.1 run程序

要run程序, 请按照以 under 步骤operation:

  1. 打开要run 主classfile
  2. right 键点击编辑器窗口
  3. 选择"Run 'MainClassName.main()'"

5.2 debug程序

要debug程序, 请按照以 under 步骤operation:

  1. in codein设置断点 (点击行号 left 侧 空白区域)
  2. 打开要debug 主classfile
  3. right 键点击编辑器窗口
  4. 选择"Debug 'MainClassName.main()'"
  5. in debugtool窗口in, usingdebug控制按钮 (继续, 暂停, 单步执行etc.) fordebug

5.3 查看run结果

程序run or debug 结果会显示 in 底部 Run or Debugtool窗口in. 你可以 in 这些窗口in查看输出information, errorinformation, variable值etc..

实践练习

请按照以 under 步骤completion练习:

  1. creation一个 new Javaproject, 命名 for "Calculator"
  2. configurationprojectSDK for Java 11 or 更 high version
  3. creation一个名 for "Calculator" Javaclass, implementation simple 加减乘除functions
  4. creation一个名 for "Main" Javaclass, package含mainmethod, 用于testCalculatorclass
  5. runMainclass, 查看输出结果
  6. in codein设置断点, debug程序, 查看variable值 变化
  7. formatcode, 确保code风格一致