79232280

Date: 2024-11-28 00:42:21
Score: 2.5
Natty:
Report link

This snippet would do what you are asking:

"Paste Multi-line To Single Line":{
        "prefix": "pasteMultiLineToSingleLine"
        ,"body": ["${CLIPBOARD/(\r\n|\n|\r)/ | /g}"]
        ,"description": "Paste from clipboard replacing every new line with a ' | '"
    }

The main difference is in identifying the different possible line ending characters.

Further explanation of the "body": in case someone else likes to understand the individual parts:

Reference:

[1] VSCode Snippet Variables: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variables

[2] Stackoverflow ref1: Match linebreaks - \n or \r\n?

[3] Stackoverflow ref2: Difference between \n and \r?

Reasons:
  • Blacklisted phrase (1): Stackoverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: NerdNoob