January 23, 2009 10:03 pm GMT

Cleaning up unnecessary linebreaks in Dreamweaver

by Gary Illyes


Adobe Dreamweaver CS3

Adobe Dreamweaver CS3

I think most of the developers who invested in Dreamweaver encountered at least once situation when, unexpectedly the code was filled up with empty lines. Removing each one manually is easy, but not if the code is tens of thousands of lines long.

So, there has to be a better way to clean up the code, an automation or macro maybe.

And there is. What we will do is to search with a regular expression for multiple blank lines then replace each with “\n” aka one single line.

So here are the steps you have to follow:

  1. From the Edit menu choose Find and Replace, or press Ctrl+F
  2. The Find in field and the Search fields should be Current Document respectively Source Code
  3. Check the Use Regular Expression box
  4. In the Find box copy paste the following regular expression [\r\n]{2,}
  5. Lastly, in the Replace field type \n and press Replace all

As a little help, here’s a screen-shot how the search box should look like:

Dreamweaver replace blank lines

Dreamweaver replace blank lines

Hope this info will help you as it helped me.


Comments

One Comment on " Cleaning up unnecessary linebreaks in Dreamweaver "

  1. mailinator on Fri, 24th Apr 2009 7:54 am  

    Find and replace with regular expressions in DW
    \s* Replace with
    "Notice there is a space after the *"

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

If you want to use your OpenID, fill out the field labeled "Website" with the OpenID URL. The other fields may remain empty.
Note that comments are pre-moderated.

Subscribe without commenting