Warning: Creating default object from empty value in /home/jared/public_html/wp-content/themes/canvas/functions/admin-hooks.php on line 160

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.