IntelliJ IDEA theme, font, editing area theme, file encoding modification, garbled problem

IntelliJ IDEA theme, font, editing area theme, file encoding modification, garbled problem

Theme modification

Theme modification

  • Note 1 in the figure above shows where IntelliJ IDEA modifies the theme. You can open File -> Setting in the upper left corner. On Windows systems, IntelliJ IDEA provides four sets of themes by default: Darcula, IntelliJ, Windows, Alloy. IDEA Theme. In addition to  Darcula being a black theme, the other three sets have a white background.
  • There may not be four sets of themes on other operating systems. You can choose the theme according to your own preferences. Changing the theme requires restarting IntelliJ IDEA to see the effect.

font modification

Theme font modification

Theme font modification

  • As shown in Figure 1 above, the modification of the IntelliJ IDEA theme font must be checked first  Override default fonts by . The default IntelliJ IDEA is not recommended to modify, but because the fonts contain Chinese and do not contain Chinese, countries that generally use English do not need to worry about garbled characters, but we do.
  • The aesthetics of fonts are different for everyone, but as mentioned in the previous paragraph, the font modification here needs to know a premise, that is, the font you choose must contain Chinese, such as Microsoft Yahei and Songti, which contain Chinese. And  this Courier New is  Monaco just plain English fonts.
  • If the font you choose does not contain Chinese, there may be  口口口口口 garbled problems like this in many places. For example, if the file name contains Chinese and the font is Chinese, it will become  口口口口口.
  • When modifying the theme font of IntelliJ IDEA, it is not recommended to adjust the font to a large size, because many people encounter such a situation: the display resolution is low, the theme font is large, and the tool menu, Some options in the right-click menu options are beyond the resolution display range and cannot be selected. Of course, if you must change the font size and don't need a large-resolution display, you can  Menus and Toolbarsdelete some menus you think you don't need through IntelliJ IDEA, but this is generally not recommended.
  • When you need to pay special attention, if you install a new font when you open IntelliJ IDEA, you must restart IntelliJ IDEA to find the newly installed font in the drop-down list.

Code editing font modification

Code editing font modification

  • As shown in Note 1 in the figure above, the default IntelliJ IDEA cannot directly modify the font on the default code template, you need to make  Save As a copy first, and then you can modify it. This design is also true for many other settings in IntelliJ IDEA, so if you see buttons with options like  this Copy, you Save As should think of this design idea.
  • As shown in Note 2 in the figure above, the checked  Show only monospaced fonts means that the monospaced fonts on the display system are filtered. Since there are not many monospaced fonts on Windows systems, there are very few drop-down fonts to choose from when this option is checked. When unchecked, all installed fonts on the system will be displayed.
  • As shown in Figure 3 above, the encoding font is divided into the first font ( Primary font) and the second font ( Secondary font). When some characters cannot be supported by the first font, the second font will be used to support them.
  • My personal habits: use English fonts  Monaco, because this font does not support Chinese, so I set this as the first font, and the second font is used  Yahei Consolas Hybrid for support, and this font contains Chinese. Neither of these two fonts comes with the system, you need to download and install it yourself.
  • 口口口口口 If your first font does not contain Chinese, and the second font contains Chinese, such problems  will still occur in some places  . For example Ctrl + Shift + N , when searching for files, if you enter Chinese, it will also change  口口口口口 . My personal file name is There is not much Chinese, so I tolerated this situation. If you are not willing to tolerate this situation, then go back to the original requirement: the first font contains Chinese.

Console output font modification

Console output font modification

  • The above picture shows the font modification of the console output content. The reason why many newcomers to IntelliJ IDEA appear garbled when making output is because there is no setting here.
  •  The principle of  console output font modification is the same as that of code editing font modification  , so it will not be explained here.

Edit area theme modification

Introduction to the theme of the editing area

Introduction to the theme of the editing area

  • The theme of the editing area, that is, the theme modification of the code writing area. Basically, everyone  General has made small changes to this on the Internet. I will also mainly introduce  General some places that I often modify on the Internet. I usually default the color modification of other features, but the modification method is the same.
  • As shown in the drop-down of the red circle in the above figure, it shows the editing area themes that my current computer can choose.
  • For the theme of the editing area, some people also make templates for download on the Internet. Here are two main sites:

Editing theme details in the editing area

Editing theme details in the editing area

  • The above figure marked 1 is the general details that can be modified
  • Note 2 in the above figure is a modifiable attribute, and not every detail can modify all attributes. For example, details: Default text it can be checked  Bold, but  Caret row it cannot be checked  Bold, because only the text has the attribute requirement of bold.
  • The mark 3 above is the modified preview area, which is displayed dynamically in real time.
  • In the  General area, I often modify the following:
  • Default textBackground , which refers to the default code text, whose properties I usually modify  .
  • Caret row, refers to the row where the cursor is located, and I usually modify its  Background properties.
  • Vertical indent guide, refers to the vertical indent line, I usually modify its  Foreground properties.
  • Identifier under caret, which refers to the effect of the same identifier at the cursor position, and I usually modify its  Background properties.
  • Text search result, refers to the style of matching characters in search mode, and I usually modify its  Background properties.

file encoding modification

file encoding modification

  • As shown in mark 1 in the above figure, the default encoding of the IDE is  UTF-8, Project Encoding although the default is  GBK, but generally I recommend changing it to  UTF-8.
  • As shown in the figure 2 above, IntelliJ IDEA can  Properties perform special encoding settings for the file, and it is generally recommended to change  UTF-8it. One of the key points is attributes  Transparent native-to-ascii conversion.
  • As shown in mark 3 in the figure above, for  Properties files, important attributes  Transparent native-to-ascii conversion are mainly used for conversion  ascii, and generally should be checked, otherwise  Properties the comments in the file will not be displayed in Chinese.
  • As shown in Note 4 in the figure above, IntelliJ IDEA not only supports encoding settings for the entire Project, but also supports encoding settings for directories and files. If you want to set the encoding for the directory, there may be  Convert a pop-up operation selection that requires encoding. It is strongly recommended  to back up the files before conversion, otherwise the conversion process may become garbled and cannot be restored.

file encoding modification

  • As shown in the figure above, to modify the encoding of individual files, you can also click the encoding setting area in the lower right corner. If the content of the code contains Chinese, the operation selection in the demo will pop up.
  • Reload Indicates that the new encoding is used to reload, the new encoding will not be saved to the file, and the file is reopened, the old encoding is still what it is.
  • Convert Indicates that the new encoding is used for conversion, the new encoding will be saved to the file, reopen the file, and what the new encoding is.
  • Code files containing Chinese Convert may cause Chinese to become garbled later, so please make a backup when converting, otherwise the conversion process may become garbled and cannot be restored.

Compilation errors due to encoding issues

  • Compilation error: 找不到符号, 未结束的字符串文字 etc. Solutions:
  • Because UTF-8 encoded files are divided into  有BOM and  无BOM out, the compiler used by IntelliJ IDEA by default is  javac, and this compilation can only compile  无BOM files. Many Eclipse users often encounter this problem when using IntelliJ IDEA to develop Eclipse projects. question. Mainly because Eclipse's compiler is  Eclipse, this compiler supports  有BOM file compilation. Therefore, the solution is to perform BOM removal for this file.
  • To remove BOM in batches, you can Google: 批量去除 BOM, 批量转换无 BOM and other keywords. Various solutions have been provided on the Internet.
  • In addition to removing the BOM there is also setting IntelliJ IDEA's compiler to  Eclipse, but this is generally not recommended.
  • If none of the above problems can be solved, and you have confirmed that IntelliJ IDEA has all the configuration encodings  UTF-8, and the error reporting file encoding is also correct UTF-8 无 BOM , then there is another possibility that this situation will also occur: there is a problem with the project configuration file. The configuration file for project encoding is at: /项目目录/.idea/encodings.xml. If you can modify this file, you can modify it. If not, delete  .idea the entire directory and restart IntelliJ IDEA to reconfigure the project.

Tomcat console output garbled characters

Tomcat console output garbled characters

  • If your Tomcat console outputs garbled characters, and you have ensured that the console font settings above in this article contain Chinese, you can also try adding the following to the VM parameters of Tomcat:-Dfile.encoding=UTF-8
  • If you are a Mac system, it is likely to be needed.

Recommended fonts for programming

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324421393&siteId=291194637