Hello, I'm new to the community, so please forgive any faux pas on my part.
I have a Google Doc which contains character dialogue for a script. For example...
Bob: Hello!
I'm trying to use App Script to quickly reformat a large number of lines in the same vein as above, i.e. <name>: <text>. I found a pretty simple function that locates any instance of ": " and replaces it with a newline:
function myFunction() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
body.replaceText(': ', '\n');
}
This part works successfully. My initial example becomes...
Bob
Hello!
My problem is that \n appears to be a soft line break, as though I'd pressed Shift+Enter in the Doc. If I try to indent either "Bob" or "Hello!", it indents both of them rather than just the one I've selected. I've tried using \r, but I get the same issue.
Is there a code for a hard line break, equivalent to pressing Enter in the Doc, that doesn't tie the formatting of the two lines together?