I'm trying to remove line and replace them by "\n" (to them add the final text in javascript with actual line)

set myCaseNote to "e.g

set AppleScript's text item delimiters to {return & linefeed, return, linefeed, character id 8233, character id 8232}
set myCaseNote to text items of myCaseNote
set AppleScript's text item delimiters to {" "}
set myCaseNote to myCaseNote as text

I can manage to remove the line but I can't replace them with the text "\n", how can I proceed ?

  • Tell us what happens when you try to add \n. What goes wrong ?
    – CJK
    May 12, 2018 at 14:45

1 Answer 1


Since you didn't actually say what's going wrong when you try to insert \n into your string, I had a little think and then I remembered that there's a setting in Script Editor:

Script Editor settings on macOS

So, if I'm guessing along the right lines here, I'm suspecting you currently have this option unchecked, which means that whenever you try to type an escaped line-break like "\n", Script Editor automatically replaces it with a physical line-break whilst you're editing, which then leads to your syntax error issues with JavaScript.

[ Don't forget to escape the newline character twice before sending it to your JavaScript code if doing so within AppleScript: \\n. If you are entering it directly into the developer console inside the web browser, the single escape \n is fine. ]

So, Option 1, is to adjust this formatting setting in Script Editor. Option 2 is to stop using Script Editor and use something like Script Debugger or Atom.

  • Yes, the Formation Option change everything alright. everything it's working now, I can remove the line and add them back with this as \\n so I can sent them to my javascript (the previous question that you also solved) thank you
    – Kevin
    May 12, 2018 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .