Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Does IntelliJ IDEA Support Auto-Save of Files?

No, with IntelliJ IDEA you never need to worry about saving your files when you switch to another application, compile or run your code, perform a VCS operation and so on. Files are saved automatically on every frame deactivation. In addition, as an additional safety measure, you can enable auto-save if the application is idle for a specified period of time. By default, auto-save on idle takes place every 15 seconds by default. By opening the Settings dialog box, you can change the auto-save period in the General tab. In case you need to roll back any unwanted changes, you can use Local History--the IntelliJ IDEA built-in version control system.

How Do I Complete Code in IntelliJ IDEA?

In IntelliJ IDEA you have three types of completion that work differently so that you can always pick what's best for the code you're working on.

When you just need to quickly complete an obvious statement, you press Ctrl + Spaceand it's done. This is referred to as Basic Completion or Instant Completion. Basic completion comes handy also when you want to look at the full list of choices available in the current context or need to complete a keyword.

If you need more precision, but don't want to scroll through a possibly very long list of options, you then use Ctrl + Shift + Space to narrow the selection down by the expression type. This is referred to as Smart Completion and it basically filters the list for you so that you can get what you need more quickly. If you invoke Smart Completion a second time it will even show you the symbols that can be reached through a chained method call.

The third type of code completion is Class Names Completion and it is activated through Ctrl + Alt + Space. It works by suggesting a class name from the letters you just type. It uses the typed letters as a substring to be contained in the class name or as initials of words that may form the actual class name. If the class requires an import statement, the right import statement is also added to the source file.


For more information, have a look at:

Is Virtual Space Enabled in the Editor?

Yes. In Eclipse, the editor virtual space is disabled by default; in IntelliJ IDEA, instead, the setting is enabled by default. To change the setting, go to Settings dialog box and select the Editor node. In the right pane, you just uncheck the Allow placement of caret after end of line option.

By default Eclipse highlights all occurrences of the identifier that is currently under the caret. To enable this same behavior in IntelliJ IDEA, select Highlight usages of element at caret in the same dialog box shown above.

Finally, note that IntelliJ IDEA poses an upper limit to the number of editor tabs you can keep open at the same time. This number is adjustable via the Settings dialog.

When the maximum number of tabs is reached and you open a new file then the one with the less frequently used file is automatically closed. This behavior, however, can be modified through the same settings page as above.

Does IntelliJ IDEA Support Code Templates?

Yes, sure. Code templates are predefined code snippets invoked by typing an associated abbreviation. For example, in IntelliJ IDEA by writing fori and then typing Tabyou expand the abbreviation to the following:

Note that sometimes code templates may include parameters that are used to automatically adjust code to the insertion context.

In IntelliJ IDEA, you configure code templates through the Settings dialog. You click File →  Settingsor press Ctrl + Alt + Sto bring up the Settings dialog box and then select Live Templates from the IDE Settings block. Using the controls on the right you can add and remove code templates.

The most notable difference between code templates in Eclipse and IntelliJ IDEA is in the bag of predefined templates you find out of the box in IntelliJ IDEA.

What are Code Inspections?

IntelliJ IDEA comes with a static code analysis tool that scans your code looking for specified patterns and templates. The ultimate goal of a static code analysis tool is detecting aspects of code which may originate compile errors or run time exceptions.
For code inspections to work nicely, you must provide a list of issues IntelliJ IDEA has to look for. Such configuration is known as an inspection profile and defines the types of problems to be sought for, severity of these problems, and color scheme of alerts. Inspection profiles can be defined at the IDE and project level. IDE level profiles are available in all projects created on the current machine. Project level profiles can be used by all team members that have access to a given project. To configure inspection profiles, you open the Settings dialog and click on Inspections within the Project Settings area.
The inspections dialog box allows you to add or remove a particular inspection from the profile. Note that you can also configure inspections on the fly when you get a notification of a code issue. A notification consists of a bulb icon displayed close to the code that didn't pass the inspection. You press Alt+Enter to open the menu that lets you configure or suppress the inspection for the current file or even the entire project.
IntelliJ IDEA comes with a long list of predefined inspections just out of the box. Eclipse lacks a similar feature, but it can count on some ad hoc plug-ins such as FindBugs which offer a service that can be compared to code inspection to some extent.

  • No labels