Posted by Emmanuel ® , 09/14/2022, 10:36:01 | Reply | Forum |
What is the best practice when creating an Instant Text entry that transforms text?
To elaborate on this topic, we will create a simple Instant Text entry that uppercases text.
Let us distinguish the cases where the text to transform is:
Typing a short form while the text to transform is already selected is not an option because it overrides the selection. To see it yourself, create an entry using the Upper Case command:
Short | Expansion |
---|---|
uc |
{UpperCase}{NoSpacing} |
Expand that entry to uppercase the selected words united states:
You will see that typing uc; overrides the selection before the UpperCase command has a chance to do its job.
To circumvent the fact that typing a short form overrides the selection, create a Hotkey Glossary Entry instead:
Short | Expansion |
---|---|
Ctrl U |
{UpperCase}{NoSpacing} |
Typing Ctrl U does not override the selection which allows the UpperCase command to do its job.
With no selection yet, we need to insert keyboard commands to establish the selection before the UpperCase command. The following entries are designed to uppercase 1, 2 or 3 words to the left of the cursor:
Short | Expansion |
---|---|
uc1 |
{Ctrl Shift Left 1}{UpperCase}{NoSpacing} |
uc2 |
{Ctrl Shift Left 2}{UpperCase}{NoSpacing} |
uc3 |
{Ctrl Shift Left 3}{UpperCase}{NoSpacing} |
The drawback of this approach is that you need different expansions for different selections.
A subtle trick is to insert a Stop command before the UpperCase command:
Short | Expansion |
---|---|
uc |
{Stop}{UpperCase}{NoSpacing} |
Expanding this entry allows you to uppercase the text in 2 steps.
We consider the expansion using Stop & Resume (see 2.2.) to be the best practice.
If you do a lot of editing, you will probably create a lot of valuable Instant Text entries that transform text. All these entries can be built on the same model as the entry to uppercase text. A good exercice to test your understanding could be to create an entry that "title cases" text, for example.
Edit | Reply | | | | | Current page | Author |