Frequently asked questions - Writer

From The Document Foundation Wiki
< Faq‎ | Writer
Jump to: navigation, search

How to allocate a keyboard shortcut to a special character

The menu Tools ▸ Customise ▸ [tab] Keyboard allows you to allocate a shortcut only to the actual launching of the Insert ▸ Special Character command.

There are however three different ways to obtain the desired result.

Using AutoCorrection

  1. Go to Tools ▸ AutoCorrect Options
  2. Enter in the Replace box the characters that you want to replace by the special character.
  3. Right-click in the With box, then choose Special character and select the character you want (it is also possible to paste this character in if it is present on the clipboard).

Note : AutoCorrection requires that the text to be replaced be "isolated" by preceding and following spaces at the time of capture.

Creation of an AutoText

  1. Insert the special character into a document.
  2. Select the character and go to Edit ▸ AutoText.
  3. Choose the category in which the AutoText will be stored (My AutoText for example).
  4. Give it a name and a shortcut.
  5. Click on the AutoText button followed by New.
  6. Close the dialog.

Note : As with AutoCorrection, the capture of the "shortcut" should in principle be preceded and followed by spaces in order that the code be recognised. AutoText however permits this limitation to be overridden by selecting the shortcut before hitting the F3 key (cf. the note in this FAQ).


Using a macro

It is possible to record the insertion of a character in a macro (menu Tools ▸ Macros ▸ Record macro) without requiring any particular knowledge of programming. [1]. Then allocate the macro to the keyboard shortcut concerned.

The advantages of this solution of allocating a macro to a keyboard shortcut are :

  • The insertion is effectively bound to the shortcut : it is not necessary to insert "replacement" text (AutoCorrection or AutoText).
  • The shortcut can be defined for several modules.


Example of a recorded macro :

sub InsertCharSpec
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Symbols"
args1(0).Value = "©"
args1(1).Name = "FontName"
args1(1).Value = "Times New Roman"

dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())

end sub


Notes:

  1. If this command is not available, you will need to activate it by using Tools ▸ Options ▸ LibreOffice ▸ General ▸ Enable experimental (unstable) features or from version 4 by Tools ▸ Options ▸ LibreOffice ▸ Advanced