48

Bookmarks in Eclipse, set and go using hotkeys, do they exist?

Say, Ctrl+Shift+1 = Set 1 bookmark

Ctrl+1 = go to the place first bookmark was set

Paco Abato
  • 3,920
  • 4
  • 31
  • 54
EugeneP
  • 11,783
  • 32
  • 96
  • 142
  • 4
    This is how Embarcadero's IDEs work. I really miss this functionality in Eclipse too :( – Math Jul 01 '13 at 14:13
  • 1
    Check the question about anonymous bookmarks: http://stackoverflow.com/q/9752024/1097104 – Juuso Ohtonen Sep 05 '13 at 06:05
  • 1
    See (and please accept) the answer from `Pierre Thibault`. Quick Bookmarks allows you to configure bookmarks nearly identical to the fantastic Embarcadero IDE bookmarks... – AlainD Jan 28 '17 at 00:17
  • Use IntelliJ, because Eclipse is obviously a low-level product in comparison. – Dmitriy Popov May 11 '20 at 14:35

7 Answers7

38

Yes. You need to set a shortcut key for Add Bookmark. Go to Window > Preferences > General > Keys and enter the text filter "bookmark". Add bookmark will be listed, select it. Now bind a new shortcut in Binding. Make sure that there are no conflicts.

bookmarks

It may be also a good idea to assign a shortcut to "Show View (Bookmarks)" where all your bookmarks are listed. Alternatively this can be enabled via Window > Show view > Other (shortcut Alt+Shift+Q, Q) > and filter to "bookmark".

From here on, you can set new bookmarks. Eclipse will want you to name your bookmarks.

You can navigate these bookmarks, using "Next Annotation" Ctrl+. and "Previous Annotation" Ctrl+, but you need to enable jumping to bookmarks first via the dropdown of these two in the annotations toolbar:

annot toolbar

image source: tutorial by vogella

So select any of the two dropdown and enable "Bookmarks":

Bookmarks

If you don't want other annotations such as Errors and Warnings to be included in the navigation, disable them in the toolbar dropdown for next/previous annotation.

The shortcut for Next/Previous Annotation can also be changed in the Preferences. Their category is Navigate, when: In Windows, you can filter to their names: Next and Previous.

Lernkurve
  • 20,203
  • 28
  • 86
  • 118
n611x007
  • 8,952
  • 8
  • 59
  • 102
  • 2
    I was wondering, any ideas on how to 'remove' a bookmark via a shortcut key? The "Keys" list offers only the option to make a shortcut for "Add bookmark" but there is no "Remove bookmark" command listed there. I was hoping that simply pressing my new keyboard shortcut for "Add bookmark" would also delete it (ie, act like a toggle), but unfortunately it doesn't work that way). – Gurce Sep 29 '15 at 04:38
13

I was not really satisfy with what Eclipse has to offer. But I found a plugin called Quick Bookmarks. See Quick Bookmarks. I love it! I can assign a shortcut to a specif bookmark. Just what I needed. It works with every text file.

Pierre Thibault
  • 1,895
  • 2
  • 19
  • 22
  • This works for Eclipse Mars (4.5). You must first install the Eclipse Marketplace (see http://stackoverflow.com/questions/5285623), replace `juno` with `mars`. Then install `Quick Bookmarks plugin` (1.2.1 and by domui.org at time of writing). Then Window > Preferences > General > Keys and assign `Set Quick Bookmark 1` to `Ctrl+Shift+1` (etc) and `Goto Quick Bookmark 1` to `Ctrl+1` (etc). Now you have Borland-style bookmarks...awesome! – AlainD Jan 30 '17 at 11:40
13

Not exactly.

You can only assign a shortcut to add a new bookmark (like I did in the picture below).
But you can go to the bookmark you have just defined only through the "Bookmarks" View (the second shortcut would only display the Bookmark view)

http://img84.i_mageshack.us/img84/6631/eclipsebookmark.png

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    The annotation preferences (General -> Editors -> Test Editors -> Annotations) has a "Include in the next/previous navigation" which might help. (Ctrl+, / Ctrl+.) – Andrew Niefer Jun 29 '10 at 16:57
8

I personally like these settings:

  1. Go to Window > Preferences > General > Keys
  2. Type "bookmark" as the filter and select "Add Bookmark"
  3. Click in the box related to binding at the bottom.
  4. Erase previously assigned hotkeys with delete or backspace Then hit Ctrl + Shift + A
  5. Similarly select "Go to next bookmark" and assign Ctrl + B to it.
  6. Finally, select "Toggle Bookmark" at the bottom, and assign Ctrl + Shift + B to it.

This way you can:

  • hit Ctrl + Shift + A to add a bookmark with name (which is shown if you open the Bookmarks view with the name you entered and you can double click on it to go to that line).
  • hit Ctrl + Shift + B to add a bookmark without name (which is also shown in the Bookmarks view but named as "Quick bookmark").
  • hit Ctrl + B to switch between bookmarks and is very handy if you have a few number of bookmarks.
Keshan Nageswaran
  • 8,060
  • 3
  • 28
  • 45
Alisa
  • 2,892
  • 3
  • 31
  • 44
  • This is exactly what I wanted except I don't have a key called 'Toggle Bookmark', did you need a plugin for this? – user2802557 Nov 28 '17 at 15:25
  • 1
    @user2802557 , There's no need to install a plugin for it. Just follow the instructions. It seems that they've changed the names; instead of "Go to next bookmark" there is "Show in (Bookmarks)" and instead of "Toggle bookmark" there is "Show view (Bookmarks)". Also they don't work as the used to; hitting the keys now just opens the bookmarks page so you can click on them. I don't know the reason. Probably this is a bug for Eclipse. – Alisa Nov 28 '17 at 17:13
  • 4
    I would want the Toggle Bookmark to be able to add or erase a bookmark, seems this functionality doesn't exist. – user2802557 Nov 28 '17 at 17:22
  • You can add the bookmark in the way mentioned in the answer though. For deleting or renaming the bookmark, you can right click on the respective bookmark in the bookmarks view (after pressing Ctrl+B), and then choose delete. Or click on it and edit its name, or double click on it to go to its position. – Alisa Nov 28 '17 at 20:46
  • 2
    I agree with @user2802557, the Eclipse way of handling bookmarks is different to how many other editors work. In editors such as Sublime, there is a very quick workflow between quickly adding bookmarks, navigating through them and quickly removing them again. The provided answer and comments are still correct, just Eclipse doesn't seem to provide that lightweight bookmarks handling. – Janos Jul 02 '18 at 08:57
3

In Eclipse 3.5 there are some bookmarks related actions cthat can be linked to key shortcuts: to bind them you have to go to menu Window > Preferences > General > Keys and use the word "bookmark" as filter.

Saluti

Lernkurve
  • 20,203
  • 28
  • 86
  • 118
pbanfi
  • 1,885
  • 2
  • 19
  • 23
3

I don't think so. You can assign a shortcut to make bookmarks, but I don't think you can specify a hotkey for each individual bookmark you create.

In Eclipse 3.5, if you go to Windows > Preferences > General > Keys you'll find the Add Bookmark command. Add a hotkey in that dialog.

Then go to Window > Show View > Other... > Bookmarks to display the bookmarks tab.

Eclipse bookmarks tab

As you would probably expect, double-clicking the entries in the bookmarks tab takes you to the bookmarked line of code.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
0

Additional info: I've got Eclipse Kepler (v4.3) and as mentioned earlier, I've seen a few more bookmark commands available. Of particular interest is the "Next Bookmark" command, which is worth binding a keyboard shortcut to. This will work similar to the "Next Annotation" command, except only jumps to the bookmarks.

Warning: I've noticed that if you edit a file outside of eclipse and then return back to eclipse, you will have lost all your bookmarks, not nice.

Gurce
  • 592
  • 7
  • 18