Search code examples
powershellnotepadbackticks

Understand how to use backtick with notepad(MS)


if I do with powershell that

    [string]$text = "this `nis a `ntest"
    $text > c:\test.txt

with notepad++ this is the result:

    this
    is a
    test

but if I open it with notepad of windows it doesn't work:

    this is a test

why that? how can I fix it?


Solution

  • Notepad exclusively uses Windows CRLF EOL markers. To get your line breaks to show in Notepad, use this:

    `r`n
    

    Reasonable text editors (read: almost everything but notepad.exe - I'm partial to Notepad++) handle all EOL styles properly - CRLF, CR, and LF.