Book Image

IntelliJ IDEA Essentials

By : Jaroslaw Krochmalski
Book Image

IntelliJ IDEA Essentials

By: Jaroslaw Krochmalski

Overview of this book

Table of Contents (17 chapters)
IntelliJ IDEA Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

An overview of the workspace


Basically, the workspace in IntelliJ IDEA consists of the main editor with tabs, menus, and many tool windows.

Tool windows

The tool windows are hidden, by default, in Version 13 and later of IDEA. You can toggle them on and off using the button in the bottom-left corner of the screen:

Tool windows are those little "tabs" visible at the edges of the workspace. These edges are called tool window bars, as shown in the following screenshot:

Some of the tool windows are always available, such as Project or Structure, while some of them are available only when the corresponding plugins are enabled.

You can arrange the order of the tool windows by dragging them with your mouse. You can drag the tool window to other screen edges as well.

Tip

There's a fourth tool window bar available at the top of the screen, which is hidden. Just drag any tool window to the top of your workspace to use it, as shown in the following screenshot:

View modes in tool windows

The tool windows have a context menu available when you right-click on them. The context menu contains items specific to a particular tool window and some possible view modes, as shown in the following screenshot:

Pinned Mode

The pinned tool window will stay open even when it becomes inactive by losing focus. You may prefer to have the Project tool window pinned to have a constant overview of the project structure. Only docked windows can be pinned. On the other hand, you can keep the project view closed almost all the time and simply use the keyboard shortcuts to navigate. On large projects, this approach is much faster than searching the tree manually for your file.

Docked Mode

When docked, the tool window will share the total workspace area with other workspace elements such as the editor. On the other hand, when undocked, the tool window will overlap the other workspace elements when resized. An undocked window will go away if inactive. For example, it is especially useful to have the console tool window undocked and resized; reading huge logfiles or console output will be a lot easier.

Floating Mode

Floating, as the name suggests, allows the tool window to float over the workspace and be detached from the screen edges. It may be useful when you work on multimonitor environments with huge display resolutions set. There are no limiting factors for the number of floating windows shown simultaneously. When floating, tool windows can be easily arranged to suit your needs.

Split Mode

The tool window will share the tool window bar with other tool windows when it has Split Mode enabled. This gives you the ability to see two tool windows at once. It's nice to see the project structure and file structure at the same time, as shown in the following screenshot:

When you use the Ctrl + left-click (PC) or cmd + left-click (Mac) keyboard shortcuts, the splitter between the two tool windows is displayed at once; IntelliJ IDEA will switch them to the wide screen mode and display them in a horizontal layout. It is priceless when you work on a fancy panoramic display and would like to use the screen space effectively, as shown in the following screenshot:

Tip

You can quickly go to the specific tool window by using the mnemonic shortcut displayed before its name, for example, Alt + 1 (PC) or cmd + 1 (MAC) will take you to the Project tool window. It works for hidden tool windows, too.

Multiple views in tool windows

Some tool windows have more than one view available. For example, the Project tool window can show Project, Packages, or Problems, as shown in the following screenshot:

These views can be made visible as separate tabs by selecting Show views as tabs in the tool window context menu:

When you have your tool windows set up, it may be a good idea to back up your current layout. You can save the way the tool windows are currently arranged by navigating to Window | Store Current Layout as Default in the main menu. You can always load the saved workspace layout by navigating to Window | Restore Default Layout or pressing Shift + F12.

You can quickly open your last active tool window by using the F12 (PC) or Fn + F12 (Mac) keyboard shortcut. To make this shortcut work on Mac, you first need to adjust the F12 system shortcut behavior in the System Preferences window available in the Apple menu. To quickly hide/unhide all tool windows and focus on the editor, press Ctrl + Shift+ F12 (PC) or cmd + Fn + Shift + F12 (Mac).

Tip

The Esc key will always get you back into the editor.

When switched off, you can temporarily show the tool window bars by pressing the left Alt key (PC) twice or tapping and holding down the left cmd button (Mac). This way, you can switch tool windows swiftly and save screen space at the same time.

Navigating inside the tool window

If the tool window contains a list (and most of them do, actually) to navigate or search inside the tool window, focus on the tool window, and just start typing the search text. It doesn't matter if it is a project or another tool window: IntelliJ IDEA will search for the characters you typed on the fly, as shown in the following screenshot:

Tool windows set up for a specific project

There is a very useful plugin you can find in the IntelliJ IDEA plugin repository named ToolWindow manager. We will talk more about installing plugins later in this chapter.

This plugin makes tool window buttons available to be controlled on a per-project basis. It allows the creation of tool window profiles, that is, you can set specific tool windows to be hidden for one project and shown for another. This is the way to keep your IDE clean and tidy.

To access the settings, go to Window | Tool Window Management | Configure Preferred Availabilities from the main menu, as shown in the following screenshot:

Next, set up preferences for particular tool windows. Select Hide to switch off the specific tool window and Show to turn it on, as shown in the following screenshot:

Editor tabs

An important part of the workspace is the editor tabs. They represent opened files and have a context menu with file-specific options, such as adding a file to a favorites list or using version control on the file.

Tabs are great to switch files, but there is a drawback here. They occupy some of the editor space when you have many files opened. The limit of the visible tab count can be set by navigating to Settings | Editor | General | Editor tabs (PC) or IntelliJ IDEA | Preferences | Editor | Editor tabs (Mac) dialog box. IntelliJ IDEA autocloses tabs if the tab count exceeds the defined limit. This is a very useful feature to reduce the tab clutter. IntelliJ IDEA will always close the least used tab.

Consider switching tabs off completely. It may sound a little weird at the beginning, but when you develop the habit of using keyboard shortcuts to navigate through opened files, you will not need tabs, and will regain some of the valuable editor space.

Tip

Use Ctrl + E (PC) or cmd + E (Mac) to display the list of opened files. Use Ctrl + Shift + E (PC) or cmd + Shift + E (Mac) to display the list of recently edited files. You can also switch between the last opened files with Ctrl + Tab and Ctrl + Shift + Tab.