Ask Your Question

setting a keyboard shortcut for line space [closed]

asked 2013-12-08 13:50:11 +0100

CrossChris gravatar image

updated 2013-12-08 13:51:52 +0100

How can I set the keyboard shortcut Alt+/ for toggling between line space 1.3 and line space 1.0?

My problems are these:

  1. how to set the line space (between current and next line) to 1.3 (and not 1.5)?
  2. how to to set a keyboard shortcut for that?
  3. how can I set the specific keyboard shortcut Alt+/?
  4. how to give a the keyboard shortcut a toggling nature which toggles between line space 1.0 and 1.3?
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-11-16 14:18:13.622276

2 Answers

Sort by » oldest newest most voted

answered 2013-12-08 16:03:36 +0100

w_whalley gravatar image

My default paragraph style is 'Default Style'. I defined a new style 'default2' with line spacing set to proportional, 130%.

I recorded a macro 'bigspace' to change the current paragraph's style to 'default2' and another macro 'normalspace' to change the current paragraph's style to 'Default Style'. How to record a macro,

I defined a global variable 'linespace' and a third macro 'switch', i.e.

sub switch
if linespace=0 then
end if
end sub

I assigned the macro 'switch' to the key 'Alt+.' since I did not find that 'Alt+/' was an available option. To assign a macro: Tools>Customize>Keyboard. Select the shortcut key 'Alt+.', then in the Functions area select LibreOffice Macros and navigate to the macro in your file called 'switch', then click the Modify button to complete the assignment.

To use this toggle: Place the cursor in a paragraph and key 'Alt+.'. The 'linespace' variable doesn't know about the spacing of the current paragraph so you may need to press 'Alt+.' twice to toggle the spacing. This will replace any paragraph style you have set manually with either the default style or the wide-spaced style so be sure that's what you want.

edit flag offensive delete link more


I think I need more info about how to define a new style default2 and how to change the current paragraph's style to default2.

CrossChris gravatar imageCrossChris ( 2013-12-08 17:22:14 +0100 )edit

Create a new style based on the Default Style this way. Key F11 to bring up the styles and formatting dialog. Default Style should be selected. Right-click it. Choose New. Change style name to default2 (or whatever). Click Indents & Spacing tab. Set Line Spacing to Proportional and the setting to 130% (or whatever). Click OK. You will have a new paragraph style.

w_whalley gravatar imagew_whalley ( 2013-12-09 02:18:49 +0100 )edit

To record a macro. (see above for more info). Start the macro recorder. Place cursor inside a paragraph. Key F11. Double-click the desired paragraph style. Key F11. Stop Recording. Save the macro in a new module (create it). Edit the macro and rename the sub from Main to e.g. widespace or whatever. Repeat with your toggle condition and create another module and macro with a different name. Now you have two macros in different modules. You can combine them in one module.

w_whalley gravatar imagew_whalley ( 2013-12-09 02:30:33 +0100 )edit

answered 2013-12-09 06:03:52 +0100

CrossChris gravatar image

updated 2013-12-09 11:53:08 +0100

Thanks to w_whalley, I could write this script which can toggle:

Global A as Integer

sub Line
    dim document   as object
    dim dispatcher as object
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("")

    dim args2(1) as new
    args2(1).Name = "TopBottomMargin.BottomMargin"
    if A = 0 then     
        args2(1).Value = 200
        A = 1
        args2(1).Value = 0
        A = 0
    end if
    dispatcher.executeDispatch(document, ".uno:TopBottomMargin", "", 0, args2())
end sub

Just assign a hotkey to the macro Line. Any improvements is appreciated.

However, the combination Alt+\ seems to be unavailable.

There's also a problem to the global variable. It should be linked the the paragraph somehow. So the it is global within that paragraph. In this way you have to use the hotkey more than one time to change. And it happens frequently.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-12-08 13:50:11 +0100

Seen: 954 times

Last updated: Dec 09 '13