Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate |
![]() Toolbox for WordPerfect |
||
Macros, tips, and
templates for Corel® WordPerfect® for Windows® |
Page updated May 26, 2023 |
|
WordPerfect
Tips Main tips page | Browse more tips |
|
Hyphens, hard hyphens,
Using "Other Codes" in WordPerfect (Format > Line > Other Codes) Edit > Paste
Special > Unformatted Text helps solve formatting problems when
copying blocks of text or macro code from the Internet or between
WordPerfect documents SoftWrap
- A macro that helps prevent long web addresses (URLs) and e-mail
addresses from wrapping to the next line as a single block of text |
From WordPerfect Help (F1): "Hyphenation 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 ["hard"] hyphen." Contents
There are four forms of hyphenation in WordPerfect — three that use hyphens and one that doesn't ☼ A hyphen (a.k.a. "regular hyphen") is normally what you get when you press the hyphen key (-), located next to the zero key (0) on a physical keyboard. Operation:
Pressing that key produces a [- Hyphen] code, visible in Reveal Codes.
This type of hyphen is often called a "regular hyphen" to distinguish it from the other types below. Hence when we speak of "hyphen" or "regular hyphen" we are referring to the same thing. Main feature: Words
containing [- Hyphen] codes will wrap ("break") at the hyphen to the next line.
The important things to remember: 1. Pressing (just) that keyboard hyphen key produces a WordPerfect format code — not a text character. The latter is usually called a "hard hyphen," which is entered into the document differently (discussed in the next section below).
2. WordPerfect also treats these two hyphen types differently in several circumstances, even though they appear identical on screen and in print. [More on this below.] Tips and notes:
• When you
use Edit, Find
and Replace to locate
a hyphenated word or number, you must use the same type of hyphen in
the Find field as exists in the item to be searched in the
document.
Hence, to find a regular hyphen, the searched item must contain regular hyphens (i.e., [- Hyphen] codes). To find hard hyphens (see next section below), the searched item must contain hard hyphens (which are text characters, not codes). It is easiest to simply copy and paste an example of the item into the Find field (or just pre-select the item before using Find and Replace, as explained here). • Similarly, you will need to distinguish between regular hyphens and hard hyphens when indexing a document (for more see here). • A word divided by a [- Hyphen] code is considered to be a single word by WordPerfect when selecting or searching for the item, and also when you ask the program to do a word count (under File, Properties). • Sometimes WordPerfect's hyphen codes do not translate to another program, so in those cases you may want to use hard hyphens (below) in the source document instead of regular hyphens. (A small, brief test should tell you.) You can search just those hyphen types (e.g., [- Hyphen] codes) and replace them (e.g., with hard hyphens) in your document with Edit, Find and Replace or with a macro (next Tip). Macro writers: Generally, searching
for a word or phrase containing regular
hyphens (i.e., [- Hyphen] codes) that are stored in a macro
variable causes the
hyphen codes to be converted to hard hyphens (i.e., hyphen characters).
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). Alternative: Search for the hyphen code using the equivalent NToC() code with something like this: vItem:=NToC(64261) SearchString(vItem) ... // etc. See example #3 in Footnote 1 below for a method of using the hyphen's NToC code in a search. Other examples: - 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 by simply pressing <Ctrl+hyphen>. Operation:
Either of the above methods produces a text character (-), which is just like any other keyboard character to WordPerfect — i.e., it's not a a format code.
Main feature: Unlike with regular hyphens (above), words
containing hard hyphens do not normally wrap ("break") at the hyphen to the next line.
[In some uncommon cases they might appear
to wrap if they are followed by a space or line- or paragraph-ending
code such as a HRt, HPg, Ln Brk, etc. — or by a hyphenated soft
return (discussed below).
However, these items are likely to have been deliberately entered by
the writer, or perhaps some automation or import procedure, or a source
program's formatting.]
Notes:
¤ Hard
(character) hyphens are automatically used by WordPerfect when pasting
hyphenated material copied from an external (non-WordPerfect) source —
either with <Ctrl+v> or with Edit, Paste Special, Unformatted
text (introduced in WP10 and later
versions, as explained here).
External sources such as Microsoft Word and internet sites do not use [- Hyphen] codes, so such pasted material will not contain them. (See Tips below about using Find and Replace to locate such character hyphens and convert the desired ones to regular WordPerfect hyphens.) ¤ A word divided by a hard hyphen is considered to be a single word by WordPerfect when selecting or searching for the item (see next Tips), and also when you ask the program to do a word count (under File, Properties). ¤ A hard hyphen can also be useful to ensure that regular hyphens in the source document are translated as character hyphens when hyphenated material is inserted into some other programs. You can search just those hyphen types — i.e., [- Hyphen] codes — and replace them with hard hyphens in your document with Edit, Find and Replace. ¤ A hard hyphen 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. [Tip: Most copy-ready documents probably should use the en-dash for such purposes.] ¤ Note especially that some "hyphens" might be created by symbols (see the WordPerfect main menu under Insert, Symbols...) and they are considered in searches to be text characters, too, not codes. They can be entered in the Edit, Find and Replace's Find field directly from the Symbols dialog or by being copied and then pasted into that field. Tips:
• When
you use Edit, Find and Replace
to locate a hard-hyphenated
word or number,
you must use hard hyphens
(not [- Hyphen] codes as in the above section) in
the Find field. WordPerfect's search function sees these
hyphen types as different things so you'll need to explicitly tell it what to
look for. (You can then use a [- Hyphen] code in the Replace field if you want to convert the hard hyphen to a regular hyphen.)
• Similarly, you will need to distinguish between regular hyphens and hard hyphens when indexing a document (for more see here). • If the hard hyphen is not produced when you press <Ctrl+hyphen> you can assign "Hyphenation Character" to the <Ctrl+hyphen> keys. (See the tip about creating such shortcut keys below.) 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.
For example: Type("ABC") MinusSign Type("123") will produce "ABC-123". Alternative: 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.] Operation:
You can insert a soft hyphen manually wherever you decide you might need one to automatically
divide ("wrap") a word at the right margin with a visible hyphen — but
only when needed, such as when the entire word would normally move as a
block of characters to the next line.
(See more below about enabling and adjusting the hyphenation zone.) There are several ways to do it: Method A
Use Format, Line, Other codes,
Soft hyphen —
or just use <Ctrl+Shift+hyphen> (which should be the factory default using the <WPWin Keyboard>).
In Reveal Codes, it produces a [- Soft Hyphen] code at the cursor location.
-or-
Method B For an
alternative shortcut you could re-assign "Hyphen Soft" to (e.g.) the
<Alt+hyphen> keys. (See the tip about creating such shortcut keys below.)
Then when holding down the <Alt> key and pressing the hyphen key it will insert a [- Soft Hyphen] at the cursor location. -or-
Method C You could record a simple macro
(Tools, Macro, Record) and click Format, Line, Other codes,
Soft hyphen, Insert. End the macro recording with the Stop
button on the property bar. [If you were to edit the macro you will see
the macro command SoftHyphen.]
The macro can then be assigned to a toolbar, menu or shortcut key; see here. When played it inserts a [- Soft Hyphen] at the cursor location. Notes: ¤ This
type of hyphen only becomes active and visible on the main editing screen
(and in print) when the joined characters span the hyphenation
zone. Otherwise you won't see it — but you will still see it in Reveal Codes as a
[- Soft Hyphen]
code.
¤ Unlike the other two forms of hyphen above, WordPerfect might count both words on either side of a [- Soft Hyphen] code separately (at least in recent versions of the program). Hence the program's word count (under File, Properties) would show such a soft hyphenated word — when the hyphen is not visible on screen (or in print) and not at the margin — as two words, not one word. Further, if the word is split at the margin the program might not even see the word during a word count, resulting in an erroneous count! ¤ You might also find this type of hyphen useful in newspaper columns or table cells. Narrower margins in such formats might also benefit from more tab stops to break words into shorter lengths when using "breaking" hyphens. Tips:
• A special soft hyphen code ([Auto Hyphen EOL]) can be inserted automatically
by the program when needed. Use Tools,
Language, Hyphenation to turn automatic hyphenation "on" and
(optionally) adjust the hyphenation zone.
Operation:
In brief, it acts like the soft hyphen above — but without using a hyphen — to automatically divide a word in the right margin's hyphenation zone when needed.
(See more below about enabling and adjusting the hyphenation zone.) Here are two ways to insert a hyphenation soft return: Method A Use Format, Line, Other codes,
Hyphenation soft return.
-or-
Method B Assign "Hyphenation
Soft Return" to the <Alt+hyphen>, <Ctrl+Alt+hyphen>
or other available hyphen key combination to create a memorable keyboard shortcut to quickly insert a hyphenation soft
return. (See the tip about creating such shortcut keys below.)
In Reveal Codes either method produces a [Hyph SRt] code at the cursor location. Practical uses: It
is often used following a slash
(stroke) mark ("/") or a dash ("—") to allow wrapping at that location.
This can be especially useful (e.g.) for long website URLs that would otherwise cause WordPerfect to move it as a block to the next line. Notes:
¤ Like the soft hyphen above, WordPerfect
might count both words on either side of a [Hyph SRt]
code separately (at least in
recent versions of the program). Hence the
program's word count (under File, Properties) would show such a divided word as two words, not one word.
Tips: • You can
use the SoftWrap
macro in the Library to automatically add hyphenation soft returns at appropriate
locations in
a block of text, such as e-mail and web page addresses, to prevent the
entire text block from
wrapping to the next line. (Just select the text first and play the
macro.)
• 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. What is a "hard" space? It's not a hyphen, but ... Hard
spaces,
like hard hyphens, are useful in several circumstances to "glue"
words, numbers, dates -- or even other heard spaces -- together to prevent them from splitting to the
next line by the program's word wrap function.
For example, they can keep items like "Mr. Roberts" on the same line. Hard spaces can be entered from the keyboard by pressing <Ctrl+spacebar>. They produce a code ([HSpace]) in Reveal Codes. [Arcane information: Normally, pressing the <spacebar> key produces a space character (ASCII 32), not a WordPerfect code (as with the hard space). On the other hand, pressing the hyphen key produces a WordPerfect code, not a hyphen character (ASCII 45). Both allow word wrapping without any extra steps.] Macro writers can insert a hard space in a document with (for example) - Type(NToC(64258)) More notes and tips ☼ 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:
![]() You can enable the checkbox to turn automatic
hyphenation on.
Notes
This is a per-document setting: Only the active document is affected. (See the related but global setting in the Tips below.) A [Hyph: On] code is inserted at the beginning (top) of the document. Tips Many 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 document. Experiment with it to see what works best for you. Adjustments The
left vertical dashed
line in the dialog's page representation represents the left boundary
of the
hyphenation
zone; the middle solid line represents the right margin; and the right
dashed 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 in the document. Specify new percentages: Increase the percentages to hyphenate fewer words or decrease the percentages to hyphenate more words. Tips and notes You
might want to also set Tools, Settings,
Environment, Prompts to your preference about when to stop and prompt
you about an item to hyphenate.
This is a global program setting and remains in effect during and between sessions until changed by you. The Prompt choices are Always, Never, or (probably the best one) When Required. After setting either Always or When Required — and if you are then prompted when editing a document — a small dialog ("Position Hyphen") appears to let you [a] insert a soft hyphen (a [- Soft Hyphen] code), [b] insert a space, [c] insert a hyphenation soft return (a [Hyph SRt] code) [d] ignore the word (typically, a [Cancel Hyph] code is automatically inserted for just that word), or [e] suspend hyphenation during editing for the document location where the program is trying to insert a hyphen (which can sometimes cause the dialog to appear multiple times at a given location as it makes adjustments). Note that the codes/spaces inserted with choices [a]-[d] are saved with the document. ☼ 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, 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. An en dash (–) is slightly wider than the hyphen (-) but narrower than the em dash (—).
It is often used to "link" dates (e.g., 2012–2013), times, complex compound modifiers (e.g., two-word proper nouns such as Seattle–Portland), or already hyphenated compounds (e.g., "pre-word–post-word formatting"). The en dash got its name because it was meant to be the same width as the letter "N". An em dash — used to separate words — was meant to be the same width as the letter "M". WordPerfect 8 (c. 1997) and later versions allow you to use QuickCorrect's Format-As-You-Go feature (QuickSymbols choice) 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.) |
Footnote 1 [...continued
from above:] One method: 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
"[- Hyphen]" text
placeholder there (but 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 just pauses at each item found (here, "Smith-Jones") until you press <Enter>. Important: The "-" between the
double quote marks in
the "Smith-Jones"
variable was inserted using the normal
hyphen key (next to the zero key). In Reveal Codes you should see a
code ([- Hyphen]), not a character (-), between "Smith" and "Jones". 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 must replace that text "placeholder" with the actual 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 This example expands on Example #2 above. It allows searching for BOTH normal hyphens -- i.e., hyphens produced with the normal hyphen key (next to the zero key) -- AND hard hyphens produced with Ctrl+hyphen keys. It does this by using a ForEach..Endfor
loop to process both forms of the hyphen -- first one and then
the other. For each item found it applies the Redline
attribute. (You can, of course, change this to another font attribute,
or just comment out -- or delete -- the AttributeAppearanceToggle()
command to disable this function). In this example the macro will search first for all instances of "Smith-Jones" where the hyphen might be a normal hyphen; then it searches for any instances of "Smith-Jones" where the hyphen might be a hard hyphen. (See the programming notes under the macro code for further explanation, especially about the use of the NToC() code.) Finally, as with Example #2: Instead of
"Smith-Jones" you can find just the hyphens whether they are hyphen
codes or hard hyphens. For example, use vStr1:=NToC(64261) only for hyphen codes and
vStr2:="-" only for
hard hyphens. (In this case you might want to enable the Pausekey()
command.) // Macro begins
here Programming
notes: [1] Note that an NToC(64261) code was used in the first variable (vStr1) above. This is equivalent to inserting a [- Hyphen] code (by pressing the hyphen key) in the macro's vStr:="Smith-Jones" command (and also in the StrTransform command) in macro #2 above. But in this example it does away with the need to use a separate StrTransform command because it already has transformed the normal hyphen code into a [Macro Func] code that the macro language can use. [NToC() codes can be useful to macro writers for many of the various items listed in the Macro Toolbar's CODES button list. The NToC() codes for each of the various 400+ listed macro functions can be found in a MacroFuncCodes (PDF) file that you can download from the Library here.] [2] Three
commands -- SearchFindWholeWordsOnly, SearchCaseSensitive,
and Pausekey(Enter!) -- are optional; hence they are simply commented
out
(///) in the macro. The Pausekey command, if enabled, will let you
pause at each item to view it. (If that command
is used, pressing Escape during macro play will
pop a message and let you exit the macro.)
■ EXAMPLE macro #4 This example expands on Example #3 above. Like Example 3 it allows searching for BOTH normal hyphens -- i.e., hyphens produced with the normal hyphen key (next to the zero key) -- AND hard hyphens produced with Ctrl+hyphen keys. However,
unlike the above examples
which hard-code variables directly in the
code (e.g., vStr:="Smith-Jones"), this macro employs
a user-input dialog to get the desired search item when you play the macro. While this method is more flexible it has a
small downside: User-input
devices such as the GetString()
command or a custom dialog will typically automatically convert a normal hyphen's format
code ([- Hyphen]) that was stored in the device's input variable
to a hard (aka, character) hyphen (-), and a
macro search
using such a converted variable will fail
to find the desired items containing hyphen codes. In short, a hard hyphen is
not identical to a hyphen code as far as the program is concerned. Solution: Use
the PerfectScript StrTransform()
command to convert the
variable's hard hyphen back into a hyphen code, then do the search
using the new converted variable. Here we assume you want to search for both
varieties of a search term such as "Smith-Jones" -- one that might
contain the hard hyphen and one that might contain the hyphen code --
you can use something like the following code. (The code should be
adjusted to fit your needs and tested thoroughly.) // Macro
begins here (ALL commands
should be on 1 line ending
with a HRt) |