This is a quick post about IntelliJ’s nice bookmark feature.
IntelliJ gives you the option to bookmark single lines of code. After a line has been bookmarked, you can use various ways to jump directly back to this line. So it can be a good idea to bookmarks code locations you often work with.
To create a new bookmark you only have to press F11 inside the code editor. Bookmarked lines show a small checkmark next to the line number.
To see all bookmarks you can press Shift – F11. This opens a small popup window which shows a list of all bookmarks you have created.
Note that this window can be completely controlled by using the keyboard:
- With Up / Down you can browse the list of bookmarks
- With Enter you jump to the selected bookmark
- Esc closes the window
- A bookmark can be moved up or down using Alt – Up / Alt – Down
Note that you can also add a mnemonic identifier to a bookmark. You do this by selecting a line and pressing Ctrl – F11. This opens a small menu in which you can choose a mnemonic identifier (which is a character or a number).
Bookmark mnemonics are also shown next to the line number. In the following image 1 was choosen as mnemonic.
Mnemonics give you the option to move even quicker between bookmarks. You can directly jump to a mnemonic bookmark by opening the bookmark popup (Shift – F11) and pressing the mnemonic key (1 in this example).
For numerical bookmarks even more shortcuts are available. You can toggle a numeric mnemonic on a selected line by pressing Ctrl – Shift – <number>. If you want to jump to a numeric mnemonic you use the Ctrl – <number> shortcut.
For example: Ctrl – 5 brings you directly to the mnemonic bookmark 5.
Note that bookmarks are also shown in the Favorites view. So if you like clicking with your mouse, this is for you!