| Barry MacDonnell's
Toolbox for WordPerfect
Macros, tips, and
templates for Corel® WordPerfect® for Windows®
| Page updated Mar 24, 2017
Main tips page | Browse tips
Hyphens, hard hyphens,
Related pages -
From WordPerfect Help (F1):
divides words that span the hyphenation zone, a
narrow area that surrounds the right margin of a document. You can
enable automatic hyphenation [see below]. You can
also change the width of the hyphenation zone. Increasing the
hyphenation zone hyphenates fewer words, and decreasing the hyphenation
zone hyphenates more words. As well, you can create a nonbreaking
There are four forms of hyphenation in
☼ A hyphen is what you get when you press the "-" key next to the "0" (zero) key.
In Reveal Codes it produces a [- Hyphen] code. Words containing hyphen codes will wrap at the hyphen to the next line. This type of hyphen is often called a "regular hyphen" to distinguish it from the other types below.
• Sometimes WordPerfect's hyphens do not translate to another program, so in those cases you may want to use hard hyphens (next item below) in the source document instead of regular hyphens.
• When you use Find and Replace to locate a hyphenated word or number, you must use the same type of hyphen in the Find and Replace fields as exists in the item to be searched in the document. Hence, to find a regular hyphen, the item must contain regular hyphens (i.e., codes). To find hard hyphens (see next section below), the item must contain hard hyphens (which are characters, not codes).
Similarly, you will need to distinguish between regular and hard hyphens when indexing a document (see here).
• Macro writers:
Searching for a word or phrase containing regular hyphens (i.e., [-Hyphen] codes) stored in a macro variable causes the hyphen codes to be converted to hard hyphens. Therefore, to use SearchString() in a macro to find such an item, you must first use StrTransform() on the variable to transform the regular hyphen code into something the macro can use.
See the example in Footnote 1 (which also has an example that does not require StrTransform since it does not first store an item with hyphens in a macro variable).
- See the code in the PageLine macro in the Library.
- See this post at WordPerfect Universe, here, which demonstrates a macro that searches for two hyphens and replaces them with an en-dash (or em-dash).
☼ A hard hyphen (a.k.a. "character hyphen," "non-breaking hyphen," or "hyphenation character") is what you get when you click Format, Line, Other codes, Hyphen character, or simply press <Ctrl+hyphen>.
¤ Hard hyphens are sometimes inserted when pasting material from another program or Internet source with Ctrl+v, or when pasting using WordPerfect's Edit, Paste Special, Unformatted text (in WP10 and later versions, as explained here).
¤ A hard hyphen acts like any other "real" keyboard character (a,b,c,1,2,3, etc.); therefore, it doesn't produce any code in Reveal Codes (the hyphen you see there is a text character, not a format code).
¤ It is often used to "glue" compound items together such as dates (2000-2003) or part numbers (123-001) so that part of the item won't wrap to the next line.
¤ It also can be useful to ensure that hyphens are translated as hyphens in some other programs.
• For easy access, you can assign "Hyphenation Character" to the <Ctrl+hyphen> keys, if it is not already assigned to them. (See the tip about creating such shortcut keys below.)
• When you use Find and Replace to locate a hard-hyphenated word or number, you must use hard hyphens (not soft [-Hyphen] codes as in the above section) in the Find and Replace fields. WordPerfect's search function sees these as two different things, so you'll need to explicitly tell it what to look for,
Similarly, you will need to distinguish between regular (soft) hyphens and hard hyphens when indexing a document (see here).
• Macro writers:
The Type() command will change hard hyphens to regular hyphens (i.e., [- Hyphen]) codes, even if they are contained in a variable that is then used as the Type() command's parameter.
You can work around this with the MinusSign command.
Type("ABC") MinusSign Type("123") will produce "ABC-123".
Use the ClipboardPut() command (new in WordPerfect 10) to store the item, then paste (not type) the item:
x:="ABC" y:="123" ClipboardPut(x +"-" + y) Paste
Result: "ABC-123" (connected with hard hyphen).
[Thanks to greg Turner at WordPerfect universe.]
¤ This type of hyphen only becomes visible on the main editing screen (and in print) when the joined characters or words span the hyphenation zone. Otherwise you won't see it (but you can still see it in Reveal Codes as a [- Soft Hyphen] code).
• A special soft hyphen code ([Auto Hyphen EOL]) can be inserted automatically by the program when needed. See Tools, Language, Hyphenation to turn automatic hyphenation "on" and (optionally) adjust the hyphenation zone.
• You can also insert a soft hyphen ([- Soft Hyphen]) manually wherever you decide you might need one. There are several ways to do it (choice [C] is the handiest for frequent use):
[A] Use Format, Line, Other codes, Soft hyphen. In Reveal Codes, it produces a [- Soft Hyphen] code at the cursor location.
[B] Record a simple macro (Tools, Macro, Record) and click Format, Line, Other codes, Soft hyphen, Insert. End the macro with Stop recording. [If you were to edit the macro you will see the command SoftHyphen.] The macro can then be assigned to a shortcut key, toolbar, or menu; see here. When played it inserts a [- Soft Hyphen] at the cursor location.
[C] You can assign "Hyphen Soft" to (e.g.) the <Alt+hyphen> keys, if it is not already assigned to them. (See the tip about creating such shortcut keys below.) When holding down the <Alt> key and pressing the hyphen key it inserts a [- Soft Hyphen] at the cursor location.
In brief, it acts like a hyphen by dividing a word but it does not show a hyphen on the main screen or in print. In Reveal Codes, it produces a [Hyph SRt] code.
It is often used following a slash (stroke) mark ("/") or a dash to allow wrapping at that location.
• You can insert a hyphenation soft return with Format, Line, Other codes, Hyphenation soft return or just <Ctrl+Shift+hyphen>. If this shortcut is not available you can assign "Hyphenation Soft Return" to the <Alt+hyphen>, <Ctrl+Alt+hyphen>, or <Ctrl+Shift+hyphen> keys if it is not already assigned to one of them. (See the tip about creating such shortcut keys below.)
• You can use the author's SoftWrap macro to add hyphenation soft returns at appropriate locations in e-mail and web page addresses to prevent the entire text block from wrapping to the next line.
• For more general needs using dashes and slashes (strokes) along with hyphenation soft returns, see the sample WordPerfect document, "Dashes and Slashes.wpd," downloadable here.
☼ Hard spaces, like hard hyphens, are useful in several circumstances, to "glue words, numbers or dates together to prevent them from splitting to the next line by word wrap.
☼ Hard spaces can be entered from the keyboard by pressing <Ctrl+space>. Normally, pressing the <space> key produces a space character (ASCII 32), not a WordPerfect code; pressing the hyphen key produces a WordPerfect code, not a hyphen character (ASCII 45).
☼ Shortcut keys: Hard hyphens, soft hyphens, and hyphenation soft returns can be assigned to the indicated keyboard shortcuts (if they are not already assigned) -- or to any available shortcut keys -- to make them easy to access while typing.
These three items are found under the Features tab in the Features category "Format," when you click on Tools, Settings, Customize, Keyboards tab, <keyboard name>, Edit. Then scroll down in the shortcut key list to find the -+Ctrl, -+Alt, etc., shortcut keys, remove the old assignment (if any), then Assign the feature to the key combination. (For more help on assigning features, macros, etc., to shortcut keys, see here.)
☼ Hyphenation zone. Hyphenation divides words that start before the left boundary of this zone (a narrow area that surrounds the right margin of a document) and extend past the right boundary of the zone. You can change it with Tools, Language, Hyphenation (earlier versions: Format, Line, Hyphenation). This is what the dialog looks like:
Enable the checkbox to turn automatic hyphenation on.
Most users find that it is best to use automatic hyphenation on the final draft of the document (if they use it at all) to minimize distractions during editing.
The left dotted line in the page representation represents the left boundary of the hyphenation zone; the middle solid line represents the right margin; and the right dotted line represents the right boundary of the hyphenation zone. The zone is measured as a percentage of the line length (determined by the current left and right margin settings).
Place the cursor where you want to change the zone.
Specify new percentages. Increase the percentages to hyphenate fewer words; decrease the percentages to hyphenate more words.
You might want to also set the prompt option in Tools, Settings, Environment, Prompts to your preference about when to stop and prompt you about an item to hyphenate: Always, Never, or (probably the best one) When Required. (If prompted, you can [a] insert a (Soft) hyphen, [b] insert a space, or [c] insert a hyphenated soft return, or ignore the word.)
☼ Re-hyphenate? If Hyphenation was turned on before you made changes, WordPerfect may prompt you to re-hyphenate some words. You can remove this message from older documents where hyphenation was previously turned on, but where it is currently turned off, with a macro: See UPDATER.
☼ You have to insert some of these items manually. Hard spaces (see above), regular hyphens, soft hyphens, and hyphenation soft returns must be deliberately inserted by the user in WordPerfect, while hard hyphens can be either deliberately inserted, imported from an external source, or converted by WordPerfect during certain "paste special" operations (see next item).
☼ Changes WordPerfect might make without telling you. If you paste material as "unformatted text" you should note the way WordPerfect 11 and later versions treat regular hyphens, soft hyphens, hyphenation soft returns, and hard spaces from a source document. See here for more (especially under the "Notes" section on that page).
☼ The en-dash is often used to "hyphenate" dates (e.g., 2012–2013), times, compound modifiers (e.g., two-word proper nouns), or already hyphenated compounds (e.g., "pre-word–post-word formatting"). WordPerfect 8 and later versions allow you to use QuickCorrect's QuickSymbols feature to create en- and em-dashes by typing either 2 or 3 hyphens consecutively. However, you may find that using simple macros that incorporate hyphenation soft returns suit your needs better since the items will then split at the margin rather than being moved to the next line. (See here for some example macros.)
Examples of macros to search for "regular" hyphens.
As noted above, storing a word or phrase
containing regular hyphens (i.e., [-Hyphen] codes) in a macro variable causes
the hyphen codes to be converted to hard hyphens. Therefore, to use
SearchString() in a macro to find such an item, you can first use
StrTransform() on the variable to transform any regular hyphens found to a code the macro can
use. This probably is most useful when storing a search item in a variable first, before doing the search. See macro #2 below.
Alternative (simpler) method:
For simple searches, you might be able to use
the Codes button on the Macro Toolbar to insert the [-Hyphen] code
between two quote marks in the SearchString() command, as demonstrated
in example macro #1 below. [Note that
this appears as [Macro Func] in Reveal Codes.] Then you can have the
macro use an old trick to convert regular hyphens to hard hyphens: Cut
the found item to the clipboard and immediate paste it back as
Unformatted text -- which changes hyphen codes to hyphen characters. (Lots of other format codes can be converted this way.)
IMPORTANT: In this macro BE SURE to insert the
actual hyphen code in the SearchString command in place of the text
placeholder there (retain the double quote marks). [To make macro #1 process just one hyphen at a time, disable or delete the SelectWord command. To make it change all found items from the cursor location forward simply enable both the While() and Endwhile commands, which currently are disabled with two slash marks.]
// Macro begins here
This example macro below uses StrTransform. It will pause at each item found until you press <Enter>.
The "-" (between the double quote marks) in the "Smith-Jones" variable was inserted in the macro with the normal hyphen key (next to the zero key).
The "-" (between the double quote marks) in the StrTransform() command below was inserted in the macro with the normal hyphen key (next to the zero key).
That is, all "-" items in the macro are actually normal hyphen codes, not hard hyphens [Ctrl+hyphen].
On the other hand, the [-Hyphen] (also between two double quote marks) in the StrTransform() command below was inserted with the Codes button on the macro toolbar. You need to replace the text "placeholder" with the Code!
Tip: Instead of "Smith-Jones" you can use just a single hyphen (inserted with the hyphen key) to find all hyphen codes. For example: vStr:="-"
// Macro begins here