Setting a keyboard shortcut for line space

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?

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, Recording a Macro - LibreOffice Help

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

sub switch
if linespace=0 then
  bigspace
  linespace=1
else
  normalspace
  linespace=0
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.

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.

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.

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.

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("com.sun.star.frame.DispatchHelper")
	
	dim args2(1) as new com.sun.star.beans.PropertyValue
	args2(1).Name = "TopBottomMargin.BottomMargin"
	if A = 0 then	  
  		args2(1).Value = 200
		A = 1
	else
		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.