TLDR: Skip to "Conclusions" at bottom of post
That is very interesting. I don’t use either %Return% or %LineFeed% in any of my production macros (have used both in testing), and I’ve never encountered an issue or negative feedback from other users.
So I really have not found any need to use %Return%. I have used the Type Keystorke with a RETURN key press often, and it always works. This is usually in the context of choosing a menu item, or creating a new line in an app. Perhaps KM is sending an ASCII 13 (0x0D) in this case to the app?
KM Editor Uses LF
It is also interesting to note that the KM Editor seems to use LF when a manual RETURN key is pressed in text areas of KM Actions.
For example, using this source string, which I typed into the Set Variable Action:
and put it on the Clipboard, then did a Search & Replace with:
The results were
SEARCH AND REPLACE of Clipboard For \n
(_LF_ will appear at EOL for all matches)
Test in Keyboard Maestro 8.0.3 (8.0.3) on macOS 10.11.6._LF_
Line with MANUAL RETURN_key_LF_
Line with token for RETURN
Line with token for LINEFEED_LF_
END OF TEST
As you can see, a match for
\n was found for every line, even the line where I had a %Return%, followed by a manual RETURN key press.
Copy From Web Page Uses LF
Another example of using LF is with this macro that I just created for a user:
I copied the source data from a KM forum page, and pasted into:
\n was found and replaced with a comma
### Choosing App Menu Can Use Either CR or LF
Note: I did NOT use a manual RETURN at the end of these lines.
Using _either_ `\r` OR `\n` (alone) resulted in the desired/expected outcome.
<img src="/uploads/default/original/3X/d/e/de4b8221e019bd81c791f88c2efdd793e49d0d02.png" width="416" height="405">
Insert Text by Typing into App (Evernote)
1. KM uses LF in the Editor for RETURN key presses
2. Copy from Web page uses LF
3. KM Execute Shell Script _requires_ LF
3. BBEdit uses LF
4. RegEx101.com uses LF
1. After extensive testing, I still find little need for `%Return%`
2. When I do want to use it, I find it more convenient, less verbose, to use `\r`, OR, if it is a KM text area, just use manual RETURN key press.
3. **LF seems to work for me in 99% of my use cases.**
<img src="/uploads/default/original/2X/9/9fa034801953dfe7d1745afcb7087c7530a06e23.gif" width="70" height="17" alt="updated" title="updated"> 2017-10-28 21:00 CT
**IMO, the best practice for most KM users**
* When typing text in a KM Action and you need a new line, just press the RETURN key.
* Don't use a token or symbol for CR or LF if don't really need to.
* If they must enter a symbol (which should be rare) for new line, the use `\n` unless testing shows it does not work. Then use `\r`.
* Use the `\R` in RegEx for matching new line characters (macOS 10.11+)
* Use `(?:\r?\n|\r)` in RegEx for matching new line characters for macOS prior to 10.11
**Personally**, I will continue to use either manual RETURN key press OR `\R` everywhere in KM, unless that fails and I have a specific reason to use `\r`.
I have no use for either `%Return%` or `%LineFeed%`, as they both just require more typing, are verbose, and have no benefit over using `\r` or `\n`.