My notes for IntelliJ's shortcuts

The following shortcuts are based on M$ Windows.


  • <C-Up> / <C-Down>: move up ↑ / down ↓ without changing cursor position.
  • <C-Alt-↑> / <C-Alt-↓>: open file explorer for the project root.

Searching / Replacing

As usual, it supports regular expressions as expected.

  • <C-F>: search
  • <C-R>: replace
  • <F3>: jump to next matching word
  • <S-F3>: jump to previous matching word

Editing / Selection

Syntax-independent shortcuts:

  • <C-d>: duplicate selected content, or the current line in case of empty selection.
  • <Tab> / <S-Tab>: indent / unindent selected line(s), like << / >> in Vim.
  • <Alt-S-↑> / <Alt-S-↓>: move selected line(s) up ↑ / down ↓ to next attribute / method.
  • <Alt-j>: select next instance that matches the currect selection.
  • <Alt-S-j>: unselect current instance that matches the currect selection. i.e. reverse of <Alt-j>.
  • <C-C-↑> / <C-C-↓>: vertically aligned carets on multiple lines.
    1. Press and release <C> once.
    2. Press without releasing <C>.
    3. Add caret(s) to neighbouring lines with and/or .

Quick code navigation and generation

Syntax-dependent shortcuts:

  • <Alt-↑> / <Alt-↓>: move cursor up ↑ / down ↓ to next attribute / method.
  • <C-S-↑> / <C-S-↓>: move selected attribute(s) and/or method(s) up ↑ / down ↓.
  • <Alt-Ins>: generate constructor, getter(s), setter(s), etc.
  • <Alt-Enter>: open popup window to resolve syntax error(s).
  • <C-Enter>: jump to definition.
  • <S-F6>: refactor current variable/method/etc.
  • <S-F10>: run program in the current configuration.
  • <Alt-S-F10>: run current class’s main method, and update the current configuration.

Remarks: I don’t add the shortcuts for debugging mode since it requires the use of mouse for breakpoint insertion.


Shortcuts for code generation.

  • main: main method
  • fori: classical for loop over an integer index.
  • collection.iter: for loop over collection

Other IDE Configurations


In .gitignore, I’m taught to use these three lines.


Class import

In settings (<C-Alt-S>), type “Java” to edit some settings in Editor → Code Style → Java:

  • Class count to use import with *: 1000
  • Names count to use static import with *: 1000

In Packages to Use Import with *, I’ve removed all packages.

shift Terminal focus

To disable escape from the Terminal by <Esc> (imagine you’re using Vim for a Git commit), you may carry out the following steps.

  1. In settings, choose Tools → Terminal on the left side bar.
  2. In the main area, under the Application Settings section, click Configure terminal keybindings.
  3. In the text field next to the magnifying glass, type “terminal”.
  4. On the right-hand side of the row Switch Focus To Editor, right-click <Esc>.
  5. In the popup menu, select the last item Remove Escape.

IntelliJ settings for terminal

Apache Log4J

Apache Log4J is a great debugging tool. Here’re the steps for its installation.

  1. Go to MVN Repository.
  2. Search “log4j”.
  3. Download Apache Log4j Core and Apache Log4j API.
    • Choose JAR file.
    • I’ve only tried version 2.17.2.
  4. In the top menu, click File → Project Structure (<C-Alt-S-S>).
  5. In the left side menu in the window, click ‘+’ then Java.
  6. Select the two JAR files downloaded from MVN Repository.
  7. Create src/log4j2.xml. Other filename doesn’t work. It can be anywhere in the app’s classpath.

add Apache log4j

I was taught to copy and paste a Rolling File Appender similar to the one on How To Do In Java.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
		<Property name="basePath">C:/temp/logs</Property>

		<RollingFile name="fileLogger"
				<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
				<TimeBasedTriggeringPolicy interval="1" modulate="true" />
				<SizeBasedTriggeringPolicy size="10MB" />
			<!-- Max 10 files will be created everyday -->
			<DefaultRolloverStrategy max="10">
				<Delete basePath="${basePathr}" maxDepth="10">
					<!-- Delete all files older than 30 days -->
					<IfLastModified age="30d" />
		<Root level="info" additivity="false">
			<appender-ref ref="fileLogger" />

Once it’s setup, it can be used by logger.error(String errorMessage).

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

public class Main {

	private static final Logger logger = LogManager.getLogger(Main.class);

	public static void main(final String... args) 
		logger.debug("Debug Message Logged !!!");"Info Message Logged !!!");
		logger.error("Error Message Logged !!!", new NullPointerException("NullError"));
  • The logger isn’t a constant, since it’s state can be changed.
  • The final keyword forbids another instance of Logger from being affected with logger.
  • The private keyword forbids other classes from accessing logger.
  • Logger follows the singleton pattern.

The debug(String message) is for development.


  1. Multiple cursors and selection ranges

(Last modified on April 14, 2023)