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.
\n (alone) resulted in the desired/expected outcome.
Insert Text by Typing into App (Evernote)
- KM uses LF in the Editor for RETURN key presses
- Copy from Web page uses LF
- KM Execute Shell Script requires LF
- BBEdit uses LF
- RegEx101.com uses LF
- After extensive testing, I still find little need for
- 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.
- LF seems to work for me in 99% of my use cases.
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
- Use the
\R in RegEx for matching new line characters (macOS 10.11+)
(?:\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
I have no use for either
%LineFeed%, as they both just require more typing, are verbose, and have no benefit over using