Non-breaking space before ; : ! ?

Is there a way to automatically insert a non-breaking space before the characters which require one in French, that is : ; ! ?

It is really time-consuming to insert the non-breaking spaces manually through Ctrl+shift+space or ALT+0160, and I imagine that all French translators encounter the same problem.

With the automatic replacement function, it only works when the character (: ; ! ?) is preceded by a space and not when it directly follows a word.

Thank you for your help!

Parents
  • Hi Christel,

    Try this:

    1. Download AutoHotkey (www.autohotkey.com) and install it. Once installed, you won't see anything open, that's normal. AutoHotkey runs in the background and allows you to run your own scripts (macros).
    2. Go to a folder in Windows Explorer where you would like to save your script (I have a folder called AutoHotkey Scripts just to keep them all in one place). Right-click on an empty space in the folder and select New-AutoHotkey Script. Give a name to your script and save it. 
    So far, you have the empty "skeleton" of a script. Now you need to enter the actions you want it to execute.
    3. Right-click on the script and select Open, then open it with a text editor, such as Notepad (I prefer Notepad++, available for free).
    4. Once the file is open, enter the following: 
    :*?:!::^+{Space}{!}
    :*?:?::^+{Space}?
    :*?:;::^+{Space};
    : up::Send ^+{Space}:
    5. Save the file. Now double-click the file, and this will load the script. Look for a green square with a white H in it in your system tray, which indicates that the script is active. Now, whenever you type one of the characters, it will be replaced by a non-breaking space + the character.
    PS: It seems that with the new forum format there is no way to mark text as code any longer.
  • If you want the most universal non-breaking space that works in any application you can use {asc 0160}.

    The script would be like this:

    :*?:!::{asc 0160}{!}
    :*?:?::{asc 0160}?
    :*?:;::{asc 0160};

    Or this one:

    :*?:!:: {!}
    :*?:?:: ?
    :*?:;:: ;

    Where the spaces you see in the script have been actually typed by pressing the sequence ALT+0160.

Reply Children
No Data