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 ⌘ + ,
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.
I borrowed a display image from the theme plugin's official website; this pinkish feel is still very nice.
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.
However, I recently discovered a font that fits my aesthetic, which is Fira Code. Here is the same piece of code displayed with it.
Font settings are in Editor -> Font
.
This mentions a setting for adjusting the font with the mouse; use Ctrl + Mouse Wheel
to set the font size.
System Settings#
Software Related#
Default Startup Options#
Set IDEA's settings for each project opening:
- New window
- Current window
- Ask, I prefer this
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.
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.
Project Encoding Related#
Show Line Numbers and Method Separators#
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.
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.
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.
#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.
Set Maven's Reload Operation#
When the
pom.xml
file changes, it will automatically trigger Maven's Reload operation.
Set Prompt for Implementing Serializable Interface#
When a class implements the Serializable interface, IDEA prompts to add
serialVersionUID
.
- Open settings.
- Search for
serialVersionUID
. - Check
Serializable class without "serialVersionUID"
. - Then, place the cursor on the class that implements the
Serializable
interface and pressOption + Enter (Mac)
/Alt + Enter (Win)
to automatically addserialVersionUID
.
This article will continue to be updated as long as I am still using the IDEA software ♪(・ω・)ノ