How to eliminate blank spaces between lines in Google Docs

I’m working with a Google Docs document that has some formatted text like this:

• item A• item B• item C

I want to convert it into a proper bulleted list format:

  • item A
  • item B
  • item C

The goal is to have no extra blank spaces between the bullet points.

I created a Google Apps Script function to handle the bullet characters and insert line breaks:

function processText() {
    var document = DocumentApp.getActiveDocument();
    var content = document.getBody();
    content.replaceText('• ', '\n');
}

This approach works partially, but when I select all the text and apply the bullet list formatting, only the first line gets a bullet point. I think this happens because ‘\n’ behaves differently from pressing the Enter key manually.

The result looks like:
• item A
item B
item C

What I really need is to replace each bullet character with the equivalent of manually deleting it and pressing Enter. This way, when I select the text and apply bullet formatting, each line would get its own bullet point.

I also tried modifying the function:

function processText() {
    var document = DocumentApp.getActiveDocument();
    var content = document.getBody();
    content.replaceText('• ', '\r\n');
}

But this creates unwanted empty lines between each item:

line A

line B

line C

It seems like there’s no straightforward way to remove these extra blank lines afterwards either.

Been wrestling with the same formatting mess for months. The issue is replaceText() doesn’t create real paragraph breaks - Google Docs can’t format lists without proper paragraphs. You need to work with the document structure directly using insertParagraph() instead of replacing text. Here’s what worked for me: find each bullet position, delete it, then use insertParagraph() right there. This creates actual paragraph elements that Google Docs recognizes as separate list items. The trick is manipulating paragraph structure, not just text content. Your current method treats everything as one giant text block - that’s why only the first line formats correctly.

Had this exact problem last month importing text. The issue is replaceText() with newlines doesn’t create real paragraph boundaries that Google Docs needs for list formatting. Here’s what actually worked: Don’t mess with it programmatically. Replace your bullet characters with a unique placeholder first (I used “###BULLET###”). Then use Find & Replace in Google Docs - put your placeholder in the find field, hit Ctrl+Enter in the replace field to insert real line breaks. Select everything and apply bullet formatting. Works perfectly. Google Docs needs actual paragraph elements, not script-inserted newlines.

Try insertPageBreak() instead of replaceText. Loop through your document, find the bullet characters, and swap them for actual paragraph breaks. Google Docs will see each line as its own paragraph, so the bullet formatting should work on everything.