Removing extra linebreaks and spaces in Dreamweaver

We use dreamweaver here at the office along with SVN for our source control. We couldn’t figure out for the life of us what what causing many, many extra lines to appear in our code after multiple commits/uploads. Finally a Google search provided the answer.

How to remove extra spaces

  1. While the document is open in Dreamweaver, press CTRL+F to load the Find & Replace dialog box. Do the search on the source code view.
  2. Check the box “Use regular expression” and uncheck any other boxes.
  3. Find: [\r\n]{2,}
  4. Replace: \n
  5. The hit “replace all”

That’s it!

However, take note that this method will remove any existing white space on your code.

Another thing. When you download the file again, Dreamweaver will add another white space on your code. Messing it up again. This is because of encoding and server type.

This usually happens if you are using Dreamweaver CS3 and your are downloading a file from a Unix/Linux server to a Windows based local PC.

Change Your Dreamweaver Settings to Prevent it

  1. Inside Dreamweaver, click Edit on the menu.
  2. Then Preferences.
  3. Then Code Format.
  4. Then on the “Line Break Type” select “LF (unix)”
  5. Click Ok. Done!

A thanks to Ryman from TechiBubble for the article.

Related posts:

  1. YouTorrent launched – I’m impressed

4 Responses to Removing extra linebreaks and spaces in Dreamweaver

  1. Kenji August 9, 2010 at 10:27 pm #

    Thank you for this tip! It is very useful.. even expert exchange is not able to provide this simple solution.

  2. Soumya February 22, 2011 at 5:52 am #

    Thank you for this solution.

  3. Dharemendra April 17, 2012 at 1:56 am #

    Working great

Trackbacks/Pingbacks

  1. How to Remove Extra Linebreaks and Spaces in Dreamweaver | Knock Some Sense - December 11, 2010

    [...] to Jared. Posted by Kenji   @   11 December 2010 0 [...]

Leave a Reply