IntelliJ IDEA Essentials
上QQ阅读APP看书,第一时间看更新

Configuration tips and tricks

In this section, you will be presented with some configuration tips, such as sharing settings and tuning IntelliJ IDEA.

Exporting and importing settings

If you have your IDE set the way you like, it may be a good idea to back up all settings. Sometimes, it's good to have common settings across all team members. IntelliJ IDEA gives you the ability to archive and export all or specific settings.

To export IDE settings to a JAR archive, do the following:

  1. Go to File | Export Settings from the main menu.
  2. Specify the settings to export the Export Settings dialog box by selecting the checkboxes next to them. All of them are selected by default.
  3. Specify the fully qualified name and path or click on the Browse button to choose the target file.

To import IDE settings from a JAR archive, do the following:

  1. Go to File | Import Settings from the main menu.
  2. Select the desired archive from the Import File Location dialog box.
  3. Specify the settings to be imported in the Select Components to Import dialog box and click on OK.

You should be really careful with importing settings. Importing a set of settings will overwrite all your settings with the imported set. For example, if you export some live templates and reimport them during a colleague's installation, the import will overwrite all their live templates with the imported ones.

Tip

There are many nice-looking themes exported this way, available to be downloaded at http://ideacolorthemes.org. Just pick and import the JAR file and check out how beautiful your IDE will look!

Sharing settings

Sometimes it's good to have the same configuration across all members of your team, organization, or the company. For this purpose, IntelliJ IDEA can use a server to store IDE settings and share them within your team.

To do this, first download the IntelliJ Configuration Server plugin, using the Plugins page of the Settings dialog box.

To connect to the IntelliJ Configuration Server, use your JetBrains account. If you don't have the account, you can create one on the JetBrains website using the link provided in the login dialog.

You can connect to IntelliJ Configuration Server in two ways: during the first startup or on demand.

During the first IntelliJ IDEA startup after installing the plugin, you can select the connection option for the next startup, such as Show login dialog, Login silently, or Do not login.

When the configuration server is connected, the green icon is displayed in the status bar, as shown in the following screenshot:

Otherwise, the red icon will be presented:

You can log in to the IntelliJ Configuration Server at any time using the button on the status bar.

The IntelliJ IDEA server stores almost all of the IDE and project settings except for those containing local paths. Your code style settings, keymaps, fonts, color schemes, and inspection profiles will be synced.

Take note that the IntelliJ IDEA server is a public, third-party server. It's secured by a username and password and uses SSL communication, but if you are very concerned about your privacy, you should share your settings using the export/import feature rather than the IntelliJ Configuration Server.

Tip

If you have to use a proxy to access the Internet in your environment, you can set up the proxy settings in the login dialog box.

Tuning IntelliJ IDEA

IDEA's Virtual Machine settings are usually very good out of the box. However, when you work on a specific huge project and decide that you want to tweak IntelliJ IDEA's own virtual machine settings, you can change that in the following locations, depending on your operating system.

On Windows, you can tweak IntelliJ IDEA's own virtual machine settings by executing the following code:

<IntelliJ IDEA installation folder>/bin/idea.exe.vmoptions

Alternatively, you can use the following code:

<IntelliJ IDEA installation folder>/bin/idea64.exe.vmoptions

On Linux and Unix systems, you can tweak IntelliJ IDEA's own virtual machine settings by executing the following code:

<IntelliJ IDEA installation folder>/bin/idea.vmoptions

Alternatively, you can use the following code:

<IntelliJ IDEA installation folder>/bin/idea64.vmoptions

On OS X, since Version 12, the file /Applications/IntelliJ IDEA.app/Contents/bin/idea.vmoptions should be copied to the following path:

~/Library/Preferences/IntelliJIdeaXX/idea.vmopti ons

In this file, you can find, or change, Java Virtual Machine settings that IntelliJ IDEA runs on. For example, to increase the IntelliJ IDEA heap size, modify the -Xmx setting. If you keep getting an OutOfMemoryError message in the PermGen space exceptions, try changing the -XX:MaxPermSize setting.

Tip

The file-scanning applications (such as Spotlight or Alfred on OS X, for example) can slow down the IDE a bit; think about excluding IDEA's folders from their scope.

Having an SSD drive to develop helps a lot with the performance. Indexing, looking for usages, and other file-related tasks will be a lot faster on the SSD drive.