Get familiar with the editor environment
| Action | Description |
|---|---|
| ⌃`⌃`⌃`⌃`⌃` | Press this shorcut to quickly switch schemes, keymaps, or view modes. In the Switch menu, select your option and press ⏎⏎⏎⏎⏎. Use the same shortcut to undo your changes. You can also find and adjust the color scheme settings in and the keymap settings in . |
| ⇧⌘F12⇧⌘F12⇧⌘F12⌃⇧F12⌃⇧F12 | Press this shortcut to maximize editor pane. |
| ⎋⎋⎋⎋⎋, ⎋ | Press this shortcut to return to an active editor from other windows. |
| ⌥F12⌥F12⌥F12⌥F12⌥F12 | Press this shortcut to return to an editor from the command-line terminal.
However, note that in this case IntelliJ IDEA closes the terminal window. To keep the terminal window open when you want to switch back to an active editor, press ⌃⇥⌃⇥⌃⇥⌃⇥⌃X, B. |
| ⇧⌘F12⇧⌘F12⇧⌘F12⌃⇧F12⌃⇧F12 | Press this shortcut to hide all windows. In this case only the editor you currently work in is open. |
| ⇧F12⇧F12⇧F12⇧F12⇧F12 | Press this shortcut to return to a default layout. In this case IntelliJ IDEA hides the Project tool window. However, you can select from the main menu to save the current layout you are working in as default and use the same shortcut to restore it. |
| F12F12F12 | Press this shortcut to jump to last active window you have used. |
Navigate inside the editor
Line numbers
Cursor position and edit location
| Action / Access | Description |
|---|---|
| ⌃⇧Q⌃⇧Q⌃⇧Q⌥Q⌥Q | Press this shortcut to find current cursor location in the editor. It might be helpful if you have a large project and do not want to scroll through the file. |
| ⌘[⌥⌘←⌘[⌃⌥←⌃⌥← | Press this shortcut to find a previous cursor position. |
| ⇧⌘⌫⇧⌘⌫⌃Q⌃⇧F2⌃⇧⌫. | Press this shortcut to navigate to the last edited location. |
| ⇧⌘E⇧⌘E⇧⌘E⌃⇧E⌃⇧E | Press this shortcut to show the list of recently edited files. |
Lens mode
To make the lens mode in the editor available on a mouse hover, right-click the code analysis marker located on the right side of the editor and from the context menu select the Show code lens on the scrollbar hover option.
Alternatively, you can perform the following steps:
- Press ⌘,⌘,⌘,⌥F7⌃⌥S to open the Settings/Preferences dialog.
- From the options on the left, select .
- From the options on the right, select the Show code lens on the scrollbar hover.
Breadcrumbs
Breadcrumbs let you navigate through the source code, by showing the names of classes, variables, functions, methods and tags in the file with which you are currently working in the editor. By default, breadcrumbs are enabled and displayed at the bottom of the editor.
- To change the location of breadcrumbs, right-click a breadcrumb, from the context menu select Breadcrumbs and the location preference.
- To edit breadcrumbs settings, press ⌘,⌘,⌘,⌥F7⌃⌥S and on the page that opens, select
.
On the Breadcrumbs page, adjust the settings and click OK.
Clear the Show HTML breadcrumbs option to hide the appearance of breadcrumbs in the editor.
Manage editor tabs
IntelliJ IDEA lets you manage the open tabs in the editor. You can close, hide, and detach them. Every time you open a file for editing, the tab with its name is added next to the active editor tab.
You can select to see what additional actions you can perform with the editor tabs.
You are able to do the following:
- To close all of the opened tabs, select on the main menu.
- To close all inactive tabs leaving only the active one, press ⌥ and click the
icon on the active tab.
- To close only the active tab, press ⌘W⌘F4⌘W⌃F4⌃F4.
- To detach a tab, drag the tab you need outside of the main window (drag the tab back to attach it) or press ⇧F4⇧F4⇧F4⇧F4⇧F4.
- IntelliJ IDEA limits number of tabs that you can open in the editor simultaneously (the default tab limit is 10).
To prevent closing editor tabs automatically after the number of editor tabs reaches its limit:- Press ⌘,⌘,⌘,⌥F7⌃⌥S.
- From the options on the left, select .
- From the options on the right, in the Tab closing policy section, adjust the settings according to your preferences and click OK.
- To switch between tabs, press ⌃⇥⌃⇥⌃⇥⌃⇥⌃⇥.
- To place editor tabs in a different part of the editor or remove the tabs, from the main menu, select and the appropriate option.
- To sort editor tabs, select from the main menu.
- To hide editor tabs if there is no more space:
- Press ⌘,⌘,⌘,⌥F7⌃⌥S.
- From the options on the left, select .
- From the options on the right, select the Hide tabs if there is no space option. Extra tabs will be placed in the drop-down list located in the upper right part of the editor.
- To split the editor window, right-click the desired editor tab, and from the context menu select how you want to split the editor window (vertically or horizontally). In this case IntelliJ IDEA makes a copy of the file and places it according to your selection. If you want to move the file without copying it first, select the Move Right or Move Down option.
Edit code
Select, move, copy code
Select, move, copy lines and code blocks
Move, remove statemets
| Action / Access | Description |
|---|---|
| ⇧⌘↑⇧⌘↑⌥↑⌃⇧↑⌃⇧↑ / ⇧⌘↓⇧⌘↓⌥↓⌃⇧↓⌃⇧↓ | To move statement, select the one you want and press one of these shortcuts. Note that if moving of statement is not allowed in the current context, the commands will be disabled. Also, note that IntelliJ IDEA moves the selected statement performing a syntax check. |
| ⇧⌘⌦⇧⌘⌦⌃⇧⌦⌃⇧⌦ | To unwrap or remove statement, place the caret on the expression you want to extract or unwrap
and press this shortcut. IntelliJ IDEA shows a pop-up window with all the actions that are available in the current context. Statements to be extracted are displayed on the blue background, statements to be removed are displayed on the grey background. You can select the desired action and press ⏎⏎⏎⏎⏎. |
Reformat and rearrange code
IntelliJ IDEA lets you reformat your code according to the requirements you've specified in the Code Style settings located in and rearrange code based on the arrangement rules specified on the Arrangement tab.
- To reformat code in the current file, in the editor, select part of the code you want to reformat(⌥⌘L⌥⌘L⇧⌘F⌥F8)
or rearrange ().
If you don't select part of the code, IntelliJ IDEA will reformat the whole file.
- To invoke the Reformat File dialog for details, press ⌥⇧⌘L⌥⇧⌘L⌥⇧⌘L⌃⌥⇧L⌃⌥⇧L.
- To reformat a module or directory, right-click the module or the directory in question and
from the context menu, select Reformat Code.
(⌥⌘L⌥⌘L⇧⌘F⌥F8 also works.) - If you need to exclude part of code from reformatting, select the Enable formatter markers in comments option
located in . Then in the editor,
at the beginning of a region that you want to exclude, create a line comment
(⌘/⌘/⌘/⌃/⌥;) and type
//@formatter:off, at the end of the region, again create a line comment and type//@formatter:on. - You can use ⌃⌥I⌥⌘I⌘I⌃⌥I⌃⌥I to quickly reformat line indents based on the specified settings
on the Tabs and Indents tab located in
, on the language page.
In some cases, the option Detect and use existing file indents for editing located in the Indent Detection section in can override your settings. In this case IntelliJ IDEA will display the appropriate notification message.
Use quick pop-ups
| Action / Access | Description |
|---|---|
| ⌥Space⇧⌘I⌥Space⌃⇧I⌃⇧I | Press this shortcut to view quick definition of a symbol (tag, class, method/function, field, etc.).
IntelliJ IDEA displays the information in a pop-up. If you need, click the icon to open the
pop-up in the Documentation tool window.
|
| F1⌃J⌥Button2 Click⌃Q⌃Q | Press this shortcut to view quick inline documentation of a symbol, press . IntelliJ IDEA displays a pop-up with the appropriate information. You can press F1⌃J⌥Button2 Click⌃Q⌃Q twice or click the icon to open the
pop-up in the Documentation tool window.If you need to change the font size of the text displayed in the pop-up window, click the icon and in the window that opens,
change the font size according to your preferences.You can also view an external documentation while in the quick documentation pop-up. Click or press ⇧F1⇧F1⇧F2⇧F1⇧F1.
External documentation becomes available when you properly configure it in the module structure. For example, in the module paths, you can add a path to a JavaDoc file, or a link to documentation; or specify a documentation URL for a library. |
| ⌃⇧Q⌃⇧Q⌃⇧Q⌥Q⌥Q | Press this shortcut to view context (the action shows the current method or class declaration when it is not visible). |
| ⌘F1⌘F1⌘F1⌃F1⌃F1 | Press this shortcut to view an error description. This action shows an error or warning description at the caret. |
| F1⌃J⌥Button2 Click⌃Q⌃Q | Press this shortcut to view quick documentation on a code element. For example, you can press ⌘O⌘N⇧⌘T⌃,⌥⇧G to look for a class and look up the documentation on any class displayed in the list. Press the same shortcut to switch focus to the pop-up. |
| ⌥⌘F7⌥⌘F7⌥⌘F7⌃⌥F7⌃⌥F7 | Press this shortcut on the element in question to see all usages for code element. |
If you want to enable/disable import pop-up messages, do the following:
- Press ⌘,⌘,⌘,⌥F7⌃⌥S.
- Select from the options on the left.
- From the options on the right, in the section, depending on the action, select or clear the Show notification after optimize imports action and click OK.
Spellchecking
For spellchecking you can use Typo inspection that highlights the code based on the pre-defined dictionaries.
You can also configure the spellchecker's custom dictionary (a file with the dic extension) in
the Custom Dictionaries Folder section located on the Dictionaries tab,
in .
- To check the spelling of the highlighted word, press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ to show the available intention actions and choose the appropriate one.
- To configure pre-defined and custom dictionaries, press ⌘,⌘,⌘,⌥F7⌃⌥S, select and specify the appropriate options.
- To configure Typo inspection settings:
- Press ⌘,⌘,⌘,⌥F7⌃⌥S and select .
- In the list of inspection types, expand the Spelling node, click Typo and configure spellchecking options.
Configure file encodings
- You can change file encoding in the editor by pressing ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ on the
encodingtag and selecting the encoding you need. - You can choose file encoding on the status bar located at the bottom of the screen.
In this case, IntelliJ IDEA opens a dialog where you can decide what you want to do with your file. You can click either Reload or Convert.
(In case of Reload, you load the file in the editor from a disk and the encoding changes are applied to editor only. In case of Convert, the file on a disk is overwritten with the encoding of your choice.) - To configure settings for file encodings, press ⌘,⌘,⌘,⌥F7⌃⌥S, select .
Editor settings
IntelliJ IDEA lets you use settings for configuring different editor options to customize the editor.
- To access settings, press ⌘,⌘,⌘,⌥F7⌃⌥S.
- To navigate inside the Settings dialog, use search field for your queries.
- To format your code, select .
Use the Code Style page to configure general settings or click the Code Style node and select the language for which you want to configure code style options such as tabs and indents, spaces, wrapping and braces, etc. You can also configure hard and soft margins on the Code Style page. - To change fonts:
- For color schemes, select .
For for the console, select . - Configure your settings and click OK.
- For color schemes, select .
- To change font size in the editor:
- Select .
- On the General page, select the Change font size (Zoom) with Ctrl+Mouse Wheel option and click OK.
- In the editor, press ^, hold it and using the wheel on your mouse, adjust the font.
- To configure font ligatures, select the Enable font ligatures checkbox located in and specify the appropriate options.
- To configure color schemes, select . If you open the Color Scheme node, you are able to configure color scheme settings for different languages and frameworks. You can also use the General option from the list to configure color schemes settings for general items such as code, editor, errors and warnings, popups and hints, search results, etc.
- To configure code completion options, select . You can configure case sensitive completion, configure how to sort your code, configure auto-display options, etc.
- To configure caret placement options:
- Select .
- On the General page, select the Allow placement of caret after end of line option.
For example, you can use this option to turn off the unlimited
whitespace in the editor.
You can also select the Allow placement of caret inside tabs option which might be helpful when you scroll your file and want the cursor to remain in the same position.
If the Allow placement of caret after end of line option is selected, the creating of the continuous vertical line will not work.
- To configure editor appearance options, for example, showing line numbers, or showing hard wrap guide, select .
- To manage long lines of code, use soft wraps that you can configure in the Soft Wraps section in .
- To configure different smart keys, select .
- To configure settings for editor tabs, select .
icon to open the
pop-up in the
icon and in the window that opens,
change the font size according to your preferences.
or press