Re-assign Ctrl-+ Ctrl-- as zoom-in/zoom-out shortcut globally

I am so used to using CTRL-+ and CTRL-- as zoom-in/zoom-out that it really annoys me when an application does not use these shortcuts. LibreOffice is one that does not.

How can I globally re-assign CTRL-+ and CTRL-- as zoom-in/zoom-out?

ctrl + mouse pad up/down is the default to do this. I know that this is not an answer to your question, but knowing this satisfied me when I had this same issue :slight_smile:

This is my first post. Feel free to provide feedback if need be.

TL/DR: Create macros. Assign key bindings.

Here’s a work-around that accomplishes the goal of zooming in and out with the keyboard. The only catch is that not only are the built in “Zoom In” and “Zoom Out” commands broken, but it appears the “Ctrl + -” and “Ctrl + +” key bindings are broken as well (I couldn’t assign any command to those key bindings successfully). I ended up choosing to use “Ctrl + 9” for zooming out and “Ctrl + 0” for zooming in as those key bindings felt as close to the key bindings I was going for as I could get. Here’s what to do:

First, add the macros. Here are the two I created:

Sub ZoomIn

Dim doc As Object
Dim new_zoom_value As Integer
Dim dispatcher As Object

doc = ThisComponent.CurrentController.Frame
new_zoom_value = ThisComponent.CurrentController.viewSettings.ZoomValue + 5
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Zoom.Value"
args1(0).Value = new_zoom_value
args1(1).Name = "Zoom.ValueSet"
args1(1).Value = 28703
args1(2).Name = "Zoom.Type"
args1(2).Value = 0

dispatcher.executeDispatch(doc, ".uno:Zoom", "", 0, args1())

End Sub



Sub ZoomOut

Dim doc As Object
Dim new_zoom_value As Integer
Dim dispatcher As Object

doc = ThisComponent.CurrentController.Frame
new_zoom_value = ThisComponent.CurrentController.viewSettings.ZoomValue - 5
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Zoom.Value"
args1(0).Value = new_zoom_value
args1(1).Name = "Zoom.ValueSet"
args1(1).Value = 28703
args1(2).Name = "Zoom.Type"
args1(2).Value = 0

dispatcher.executeDispatch(doc, ".uno:Zoom", "", 0, args1())

End Sub

In short, the macros grab the current zoom value as a percentage, add or subtract 5 percentage points, then assign the new zoom value. You can alter the percentage that the macros zoom in or out by, by altering the number at the end of the “new_zoom_value” line.

To add the macros open the IDE (Tools → Macros → Edit Macros) and past the above code into “Module1”:

Next, to assign the key bindings:

  1. Open the the “Customize” dialogue box (Tools → Customize…)
  2. Make sure the “Keyboard” tab at the top of the dialogue box is selected
  3. Select the desired key binding from the “Shortcut Keys” menu. You may have to delete the existing key binding if you’re replacing a key binding that already exist. The “Delete” key is on the right. Be aware of any key bindings that you are modifying but don’t stress too much as any changes are completely reversible.
  4. Find the first macro you wish to assign a key binding to by selecting “Module1”. It’s near the bottom of the “Category” menu in the bottom-left quadrant of the dialogue box. You have to open up “LibreOffice Macros” and drill down to “Module1” (see pic below).
  5. Select the macro you want to assign to the chosen key binding and click “Modify” in the upper-right of the dialogue box.
  6. If the desired key binding is displayed in the “Keys” box in the bottom-right quadrant then repeat steps 3 through 5 for the other macro. Finally, click “OK” and go test it out.

Here’s what it looks like AFTER clicking “Modify” but before clicking “OK”:

Note that if you go back and look at the custom key bindings in the dialogue box, the macros will show up as a line of OpenOffice.org Basic code rather than the names you assigned them but they still work just the same.

I hope this helps!

Hello, whenever I try the shortcuts I get a “Property or Method not found”. I just started using Calc, can you get me any info on what I might be doing wrong? It would be thoroughly appreciated.
It sends me back to the Macro window in this line “new_zoom_value = ThisComponent.CurrentController.viewSettings.ZoomValue + 5”

Hello, whenever I try to do this a message box appears and sends me back to the macro window with the text: “BASIC runtime error” “Property or method not found: viewSettings.” and the selected text in the Macros is: “new_zoom_value = ThisComponent.CurrentController.viewSettings.ZoomValue - 5”. Any help would be much appreciated, I just switched to Calc a couple of days ago because Excel was too restrictive for my needs.

This seems to be the only solution that works in 7.1, even with the mentioned shortcuts (Ctrl±)

This is still broken in 5.1.6.2.

The shortcut can be modifed but they don’t take effect (tried restart application).

This is bug 45705. This is not possible now for Calc or Writer (except for Print preview mode).

In LO-4.4.4 + LO-5.0.0 you can assign those functions to those keys via the Customise dialog. One of the LO apps needs to be open before you take the steps below:

Step by Step:

  • (menu):ToolsCustomiseKeyboard tab

In Shortcut Keys:-

  • select Ctrl++ (by default assigned to ‘Calculate’)
  • press Delete button to remove default assignment

In Functions:-

  • select CategoryView
  • select FunctionZoom In
  • press LibreOffice option-button to apply to all of LO
    (else press Writer, or whichever App is open)
  • press Modify button to apply the Function to the Key
  • press OK to apply the shortcut
  • repeat whole sequence for Zoom Out

If this helps then please tick the answer (:heavy_check_mark:)

Does not work in Localc/Lowriter 4.2.8.2.

Try giving a little more info; it encourage others to want to help you.

As you gave your LO version I added some extra info at the top of my reply.

I upgraded to 5.0.3.2. It still does not work. I can set the keys, but nothing happens after I press OK, and press CTRL-+ or CTRL–. I had expected the Zoom percentage in the lower right corner to change, just like it does if I do CTRL-scrollwheel.

Doesn’t work in 7.1.Worked for a while on version 7.0.6 for Linux, now it doesn’t. As said in another answer, it works in print preview. By the way, for zoom in Ctrl+= is more consistent on a US keyboard.

the aparent bug is still going in 6.0.5!.
found some information about this. there is a bugzilla thread:
https://bugs.documentfoundation.org/show_bug.cgi?id=45705&redirected_from=fdo
wich states that that the shortcuts you can assing in Tools-customize-keyboard dialog correspond to the preview mode.
Browsing the options at Writer: Tools-Cusomize-keyboard-Category=view there are many possibly related Functions.
100%,150%,200%,50%,75%,Optimal,Zoom, Zoom In, Zoom Next, and others. One of the ‘Zoom’ options acutally opens a zoom dialog that makes it possible to select a zoom level pressing a second shortcut. a shortcut at PageWidth also works.
Its not the solution, but this workaround makes the thing workable

EDIT , the day after.
in Libreoffice Draw, the following works:

  • zooms in
  • zooms out
    Num * zoom to fit entire page
    Num/ zooms to selected object.

to make this work in writer and calc would be of great help. maybe combining the keys with ctrl or super.

As a complement to the answer that worked for me, which provides a macro, I want to post here an image with the location of the settings - under Tools - Customize - Keyboard (tab) - Category: LibreofficeMacros (drop-down) - My Macros (drop-down) -Module1

Tested in Linux with LO 7.1.