banner
lMingyul

lMingyul

记录穿过自己的万物
jike

Using the Series - Common Settings of IDEA

Article update log:
2023-08-15 Added prompt for setting Serializable interface

The Using the Series records how I use software tools in my daily life. This article is part of the Using the Series - Common Settings of IDEA. Due to the internal network environment used by the company, I find that some good settings I use in IDEA at work cannot be synchronized to my home in a timely manner. Therefore, I specifically wrote this series to document the modifications I have made to this commonly used IDE during my daily development and programming to improve my coding efficiency and enthusiasm. This series will continue to be updated.

First, let me clarify that the version of IDEA introduced in this article is 2022.3.2 (Ultimate Edition), and the computer system is Mac OS 12.5 Monterey version.

Almost all settings of IDEA are in the detailed settings menu, and the shortcut key to open the settings menu is ⌘ + ,

CleanShot-2023-02-11-14-51-47@2x-2023-02-11-145344

Appearance#

First of all, a handy weapon should also be pleasing to the eye.

Theme#

I personally prefer to use a dark theme. After trying so many themes, I still like this Xcode-Dark theme the most.

CleanShot-2023-02-11-14-57-11@2x-2023-02-11-145812

I borrowed a display image from the theme plugin's official website; this pinkish feel is still very nice.

image

Font#

For programmers, the code they write is like their business card, so a good-looking font is also very necessary.

I have been using a very nice font: JetBrains Mono, which indeed looks great. Below is a display of this font's specific code.

CleanShot-2023-02-11-15-12-39@2x-2023-02-11-151316

However, I recently discovered a font that fits my aesthetic, which is Fira Code. Here is the same piece of code displayed with it.

CleanShot-2023-02-11-15-17-14@2x-2023-02-11-151742

Font settings are in Editor -> Font.

CleanShot-2023-02-11-15-20-40@2x-2023-02-11-152219

This mentions a setting for adjusting the font with the mouse; use Ctrl + Mouse Wheel to set the font size.

CleanShot-2023-02-11-15-51-59@2x-2023-02-11-155412 CleanShot-2023-02-11-16-04-27-2023-02-11-160636

System Settings#

Default Startup Options#

Set IDEA's settings for each project opening:

  • New window
  • Current window
  • Ask, I prefer this
CleanShot-2023-02-11-15-36-31@2x-2023-02-11-153709

Disable Automatic Updates#

The automatic updates of IDEA software itself do not need to be checked, as updating the entire software can easily introduce compatibility issues; it is recommended not to select it.

Plugin updates can be checked.

CleanShot-2023-02-11-15-45-58@2x-2023-02-11-154657

Adjust IDEA's Startup Parameters#

Make the IDE run more smoothly.

Find Help -> Edit Custom VM Options in the menu, and adjust JVM-related parameters such as -Xms and -Xmx in the opened idea.vmoptions file.

-Xms2048m
-Xmx8192m
-XX:+UseConcMarkSweepGC
-Djava.net.preferIPv4Stack=true
-Dfile.encoding=UTF-8
  • -Xms2048m: Specifies the initial size of the JVM heap memory.
  • -Xmx8192m: Specifies the maximum size of the JVM heap memory.
  • -XX:+UseConcMarkSweepGC: Selects the CMS garbage collector as the garbage collector when starting the Java virtual machine.
  • -Djava.net.preferIPv4Stack=true: Indicates that IPv4 addresses should be preferred over IPv6 addresses. This parameter is commonly used in handling network connections, as some older network devices may not support IPv6 addresses. If IPv6 addresses are used by default, it may lead to connection issues. By setting this parameter to true, it ensures that Java prioritizes using IPv4 addresses when handling network connections, thus avoiding connection issues.
  • -Dfile.encoding=UTF-8: Specifies that file encoding uses UTF-8 encoding format.

Show Line Numbers and Method Separators#

CleanShot-2023-02-11-16-10-16@2x-2023-02-11-161135

Code Intelligent Prompt Function#

The code prompt and completion feature has a characteristic: case sensitivity. It is recommended to uncheck this option so that code prompts appear regardless of whether you input uppercase or lowercase.

CleanShot-2023-02-11-16-15-45@2x-2023-02-11-161635

Set Project File Encoding to UTF-8#

Sometimes, code errors may arise from code encoding issues, so it is very necessary to unify the encoding format before project development.

CleanShot-2023-02-11-16-19-51@2x-2023-02-11-162104

Set Java File Header Comment Information#

When creating a new Java file, we inevitably need to write comments at the top of this file to explain some basic information about it, such as the creator, creation time, description, etc. However, manually entering this each time can be cumbersome, so IDEA provides a template for creating files, and we can customize our own template.

Since I am a Java developer, I only set the templates for class, interface, and Enum. The ${USER} in the comments is a preset variable, and other variables can be viewed on the official website.

CleanShot-2023-02-11-16-29-02@2x-2023-02-11-162947
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
 * 
 * @author ${USER}
 * @date ${YEAR}/${MONTH}/${DAY}
 *
 **/
public class ${NAME} {
}

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
 * 
 * @author ${USER}
 * @date ${YEAR}/${MONTH}/${DAY}
 *
 **/
public interface ${NAME} {
}

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
 * 
 * @author ${USER}
 * @date ${YEAR}/${MONTH}/${DAY}
 *
 **/
public enum ${NAME} {
}

Set Automatic Compilation#

The benefits of setting automatic compilation:

  • Saves time, no need for manual compilation.
  • Can promptly discover syntax errors in the code, avoiding issues when running the code.
CleanShot-2023-02-11-16-37-24@2x-2023-02-11-163847

Set Maven's Reload Operation#

When the pom.xml file changes, it will automatically trigger Maven's Reload operation.

CleanShot-2023-02-25-14-38-02@2x-2023-02-25-143856

Set Prompt for Implementing Serializable Interface#

When a class implements the Serializable interface, IDEA prompts to add serialVersionUID.

  1. Open settings.
  2. Search for serialVersionUID.
  3. Check Serializable class without "serialVersionUID".
  4. Then, place the cursor on the class that implements the Serializable interface and press Option + Enter (Mac) / Alt + Enter (Win) to automatically add serialVersionUID.
pictures pictures

This article will continue to be updated as long as I am still using the IDEA software ♪(・ω・)ノ

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.