Guides for SE student projects »

Intellij IDEA: Useful settings

Enabling assertions

This tweak does not apply if you use Gradle to run code even within Intellij. In that case, refer to 'Enabling assertions' sections of the Gradle tutorial.

  1. Choose RunEdit Configurations....
  2. Select the run configuration of interest.
  3. Click on Modify options link and choose Add VM options
  4. Add -ea to the VM options box.

Enabling soft wrapping

While it is common to enforce a maximum line length for code written in some languages (typically, for code made up of statements such as Java), it is also common not to enforce such a limit for source content that contain paragraph-like structures (e.g., Markdown, HTML). In such cases, you'll need to scroll the editor window horizontally to read the content, which can be a frustrating experience. Here's an example (notice how the text continues beyond the visible area of the editor window and you need to use the horizontal scrolling to see the hidden part):

Luckily, you can use the 'soft wrap' feature of Intellij to get the editor window to put line breaks in the content so that horizontal scrolling is no longer required. Here is how the same code from the above example looks after enabling the soft-wraps feature (notice how the whole text is visible now, due to the soft line breaks added by the editor):

Read this to find how to enable soft wraps.

Enabling automatic selection of open file

When working with a large repository, it can become quite tricky to keep track of files and where they are located. For example, you may be jumping across a few files while searching for a particular method or class and when you finally reach that class, you do not know which folder/subfolder it is located under! IntelliJ provides a setting that causes opened files to automatically show up in the Project tool window (on the left side of the IDE).

Simply go to the Project tool window, select options (the three dots), select behaviour, then click Always Select Opened File.

Now, whenever you select a file (e.g. by clicking on a method), the file will appear selected in the Project tool window, allowing you to quickly locate the file.