Removing unnecessary spaces at the end of lines in Adobe InDesign CS4

I can be slightly OCD sometimes and unnecessary spaces at the ends of lines really bug me – especially in InDesign and HTML.

To sooth my furrowed brow I turned to the trusty old find and replace function Ctrl/⌘+F, called Find/Change in InDesign Edit > Find/Change…. I copied two spaces and the paragraph separator character, pasted that into the Find what: text box and set the Change to: text box to ^p. I set the Search: dropdown to Document and hit the Change All button.

Oh dear.

All my carefully stylesheet formatting of headings and paragraphs were butchered. This isn’t what I wanted at all. I thought, “there must away to do this” and wondered if that two-problem-solution regex (GREP in InDesign), might be able to help me out.

After a couple of minutes I managed to cobble something together:


Please note the leading space!

In the replace box, just put this:


Of course, this doesn’t take into account tabs and other more exotic invisible characters. I did try putting in tabs as well in the find box, but I started getting corrupted styles again, so if anyone has any solution to the “and tabs” please post the solution in the comments.

Please post any (constructive) criticisms and improvements in the comments and I’ll update here with credits.

Leave a Reply