Do you want your ad here?

Contact us to get your ad seen by thousands of users every day!

[email protected]

Using Bookmarks in IntelliJ IDEA

  • March 07, 2023
  • 4047 Unique Views
  • 6 min read
Table of Contents
Add anonymous bookmarksAdd mnemonic bookmarksNavigate to bookmarksSummary and Shortcuts

In this tutorial, we're going to take a look at using bookmarks in IntelliJ IDEA.

Bookmarks can come in handy while navigating a codebase, when you see something interesting that you want to come back to later.

You could use Recent Files (⌘E on macOS, or Control+E on Windows/Linux) to find it, but then you have to remember which file it was. This is where bookmarks come in handy.

Let's take a look!

Add anonymous bookmarks

We can bookmark a line by pressing F3 (on macOS) or F11 (on Windows/Linux).

This shortcut creates an anonymous line bookmark, marked with a Bookmark icon.

If we don't remember the shortcut, we can right-click the gutter next to the line of code we want to bookmark and select Add Bookmark.

Anonymous Bookmark

Add bookmark from the gutter

We can also bookmark files, packages, folders, and modules. We can open the Project Tool Window (⌘1 on macOS, or Alt+1 on Windows/Linux) and add an anonymous bookmark.

We can use the shortcut (F3 on macOS, or F11 on Windows/Linux) or we can also right-click the item we want to bookmark, and select Bookmarks | Add Bookmark. Note that anonymous bookmarks don't have an identifier, and we can create as many anonymous bookmarks as we like.

Bookmark project item

Add mnemonic bookmarks

We can also create bookmarks that are assigned to a digit (0 to 9) or letter (A to Z). To add a mnemonic line bookmark, press ⌥ F3 (on macOS) or Control+F11 (on Windows/Linux) and press the digit or letter to use as an identifier for this bookmark.

Again, we can also or right-click the gutter next to the line of code that you want to bookmark and select Add Mnemonic Bookmark.

Add Mnemonic Bookmark

Optionally, we can provide a description for the new bookmark. We can double-click the digit or letter we want to assign.

Add Mnemonic Bookmark

Lines marked with mnemonic bookmarks have the corresponding digit or letter icon in a frame.

Mnemonic Bookmark

If the selected digit or letter is already in use, IntelliJ IDEA will ask you whether you want to overwrite an existing bookmark with the new one. When we select the Don't ask again option, the IDE will silently overwrite mnemonics.

Rewrite Mnemonic Bookmark

Navigate to bookmarks

There are several options to navigate to the bookmarks we have created.

Show line bookmarks

To see all line bookmarks that we have in the code, we can open the Bookmarks popup by pressing ⌘ F3 (on macOS) or Shift+F11 (on Windows/Linux) or go to Edit | Bookmarks | Show Line Bookmarks.

Show Line Bookmarks shortcut

Show Line Bookmarks menu

Notice that this list does not contain any project items like files or classes that we have bookmarked.

We can select the bookmark we want to navigate to, either with up and down arrows and pressing Return (on macOS) or Enter (on Windows/Linux), or by double-clicking it with our mouse. For mnemonic bookmarks, we can select the corresponding digit or letter.

Bookmark popup

Jump to mnemonic bookmark

To jump straight to a mnemonic bookmark, hold ^ (on macOS) or Control (on Windows/Linux) and press the mnemonic digit or letter on the keyboard.

This doesn't work with anonymous bookmarks, but we can assign a mnemonic to an existing anonymous bookmark, either using the shortcut, or by clicking the bookmark in the gutter and selecting Assign Mnemonic.

This works in the Bookmarks popup too!

Go to Bookmark

Assign Mnemonic

Bookmarks tool window

To see all our bookmarks, we can open the Bookmarks tool window by pressing ⌘ 2 (on macOS) or Alt+2 (on Windows/Linux), or by selecting View | Tool Windows | Bookmarks from the main menu.

Open Bookmark Tool Window shortcut

Open Bookmark Tool Window menu

IntelliJ IDEA adds your bookmarks to the predefined list in the Bookmarks tool window that is created automatically and has the same name as the project. In this example, multiple bookmarks in the same file are grouped together.

We can also turn that off in the Options menu, by deselecting Group Line Bookmarks by File. As we can see, there are several other options as well. We won't dive into all of them, but be aware there are some options you can configure to your liking.

Bookmark Tool Window options

Bookmarks lists

Another option we do want to show you here is that you can create more lists.

We can add a new list using the shortcut (⌘ N on macOS or Alt+Insert on Windows/Linux) or by clicking the Create Bookmark List button. We can add a name for the new list.

Create Bookmark List

If there are multiple lists, and we create a new bookmark, we can select which list to add it to in the Add Bookmark popup.

We can also select the list to use as the default by checking the option Use as default list.

Select Bookmark List

In the Bookmarks tool window, we can move bookmarks to another list by dragging them to the other list.

And we can sort bookmarks by selecting a bookmark and using Move down (⌥ ⌘ ↓ on macOS, or Control+Alt+↓ on Windows/Linux) or Move up (⌥ ⌘ ↑ on macOS, or Control+Alt+↑ on Windows/Linux).

Move down

Fun fact: The Bookmarks tool window also shows all breakpoints that are automatically added to the dedicated list once you place them in your code.

Breakpoints

Bookmark editor tabs

Finally, we can also bookmark editor tabs. Click the ... to the right of the tabs and select Bookmark Open Tabs.

We can enter a name for this list in the Create Bookmark List popup.

Bookmark Open Tabs

Create Bookmark List popup

Summary and Shortcuts

As we've seen, bookmarks allow us to "save" certain interesting locations in the code base, so we can easily go back to them later.

Now we know how to create bookmarks and how to navigate to bookmarks we have created.

IntelliJ IDEA Shortcuts Used

Here are the IntelliJ IDEA shortcuts that we used.

Name macOS Shortcut Windows / Linux Shortcut
Recent files ⌘ E Ctrl+E
Open / Close Project Tool Window ⌘ 1 Alt+1
Add anonymous bookmark F3 F11
Add mnemonic bookmark ⌥ F3 Ctrl+F11
Open bookmarks popup ⌘ F3 Shift+F11
Jump to mnemonic bookmark ^ + mnemonic Ctrl+mnemonic
Open Bookmarks Tool Window ⌘ 2 Alt+2
Create Bookmark List ⌘ N Alt+Insert
Move down ⌥ ⌘ ↓ Ctrl+Alt+↓
Move up ⌥ ⌘ ↑ Ctrl+Alt+↑

Related Links

3 Ways to Refactor Your Code in IntelliJ IDEA

In this blog, we’re going to look at 3 ways to refactor your code in IntelliJ IDEA.

Simplifying your code has lots of advantages, including improving readability, tackling technical debt, and managing ever-changing requirements. The three types of refactoring we will look at in this blog are:

– Extracting and Inlining
– Change Signature
– Renaming

8 Debugging Tips for IntelliJ IDEA Users You Never Knew Existed

As developers, we’re all familiar with debuggers. We use debugging tools on a daily basis – they’re an essential part of programming. But let’s be honest. Usually, we only use the breakpoint option. If we’re feeling frisky, we might use a conditional breakpoint.

But guess what, the IntelliJ IDEA debugger has many powerful and cutting-edge features that are useful for debugging more easily and efficiently.

Apple Silicon with Zulu OpenJDK and IntelliJ IDEA

Azul has been leading the OpenJDK community effort (JEP 391) initiated in August 2020 to add support for Apple Silicon, Arm-based Macs, in future versions of OpenJDK.

In addition to targeting future Java versions, such as Java 16 via JEP 391, Azul has made OpenJDK builds of currently popular Java versions, including Zulu builds of OpenJDK 8, 11, and 13, as well as 16-ea, widely available for use on Apple Silicon, Arm-based Macs.

JavaFX application created using IntelliJ
Beginning JavaFX Applications with IntelliJ IDE

This article is for the beginner who wants to get started developing JavaFX applications using IntelliJ IDE.

While this article may seem elementary for some, I believe it can help newcomers to the JavaFX platform avoid some pitfalls and really hit the ground running.

IntelliJ IDEA Icon
Creating a Simple Spring Boot Application in IntelliJ IDEA

In this tutorial, we’ll use the New Project Wizard in IntelliJ IDEA to create a Spring Boot project with the Spring Web dependency.

We’ll also create a Spring Controller and served some text to the local Tomcat webserver.

Finally, we’ll add a test for our HTTP call.

Do you want your ad here?

Contact us to get your ad seen by thousands of users every day!

[email protected]

Comments (2)

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Uwe avatar

Uwe

3 years ago

There is a small error in the shortcut table. You have to switch anonymous (F11) and mnemonic (ctrl + F11) shortcut. :-)

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Marit van Dijk avatar

Marit van Dijk

3 years ago

Thanks for pointing that out, Uwe! Fixed now ;)

-4

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Subscribe to foojay updates:

https://foojay.io/feed/
Copied to the clipboard