How to add undo / redo buttons to toolbar in Eclipse?
Asked Answered
L

5

26

I feel a bit embarrassed asking this questions, but how the heck can I get regular undo/redo buttons into the toolbar of eclipse?

I've often to switch between German and English keyboard layout. Y and Z on those layouts is interchanged and thus I constantly trigger the wrong action for undo / redo. I've observed myself how I figure this without other editors: I just use the toolbars for this operations.

I've already tried Google and such, as well as going through the Customize Perspective dialog, but wasn't able to find what I'm looking for :-(

Lois answered 4/5, 2009 at 12:19 Comment(2)
I would change the title to "How to add undo / redo buttons to toolbar in Eclipse?"Dias
Done. I used the tags for it, I've seen this often with editors, OS, etc. and found it sufficient.Lois
C
44

One way is to use custom plugin. In fact, such custom plugin doesn't need to do anything, only declare new toolbar contribution using existing undo/redo commands.

I've built such plugin for you: http://www.foglyn.com/misc/undoredo_1.0.0.jar. There is absolutely no code, only plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
          locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
            <toolbar
                  id="undoredo.toolbar"
                  label="Undo/Redo">
            <command
                  commandId="org.eclipse.ui.edit.undo"
                  id="undoredo.undo"
                  style="push">
            </command>
            <command
                  commandId="org.eclipse.ui.edit.redo"
                  id="undoredo.redo"
                  style="push">
            </command>
         </toolbar>
      </menuContribution>
   </extension>

</plugin>

And MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Undoredo
Bundle-SymbolicName: undoredo;singleton:=true
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.ui

You can download it, and drop into your 'dropins' directory of Eclipse, restart, and you'll see Undo/Redo buttons on your toolbar.

Works for me in Eclipse 3.4 and Eclipse 3.5M7.

Calciferous answered 4/5, 2009 at 20:11 Comment(5)
Could you create a copy of undoredo.jar with .zip extension? My company's firewall blocks files with .jar extension :(Morna
@Bulletmagnet: sure, no problem. Here it is: foglyn.com/misc/undoredo_1.0.0.zipRinna
With Eclipse 4.7.0 Oxygen, the Redo button doesn't become enabled after an Undo, even though the Edit menu item does become enabled :( Switching to another tab and back enables Redo.Morna
Any instructions about how to install this?Vesicate
@ioaniatr: I haven't used Eclipse for a while, so things may have changed, but there used to be "dropins" directory inside Eclipse installation. You need to put downloaded file into this directory.Rinna
I
7

Perhaps if can't get the undo toolbar working, you can change the mapping of the Undo / Redo key combinations to ones you could become more comfortable with.

In Eclipse, go to Window > Preferences and in the left-tree, go to General > Keys.

In the 'type filter text' box, type Undo and you'll see the Undo command appear in the bottom list. You're free to change this mapping from the default Ctrl + Z to another mapping. You may likewise do the same for Redo and any other actions, such as removing trailing whitespace, etc.

Indiraindirect answered 4/5, 2009 at 19:58 Comment(0)
C
6

Edit: this is now included in Peter Štibraný's answer

Old thread, but still helpful... Made a small addition to Peter Štibraný's excellent answer. Changed the opening toolbar tag to:

<toolbar
    id="undoredo.toolbar"
    label="Undo/Redo">

This makes the new toolbar show up with the label Undo/Redo in the Customize Perspective dialog instead of showing up as a blank entry. (Don't have enough rep to add it to the comments!)

Crackpot answered 28/2, 2013 at 20:3 Comment(0)
G
4

The toolbars and menus are dependent on the current perspective. To change them go to Window > Customize Perspective...

Green answered 5/7, 2012 at 18:7 Comment(0)
M
1

2021 UPDATE

It's a quick fix in eclipse 2020-12: Window --> Perspective --> Customize Perspective --> click Edit checkbox --> Apply and Close.

That puts undo/redo buttons on the toolbar, but way to the left. To move them, click the three dots to the left of the undo button and drag to a more convenient location above your editor window.

Maxilliped answered 26/2, 2021 at 17:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.