Posted: April 16th, 2010    By: Devin Walker   

I get really annoyed when there’s unnecessary lines in code that I’m editing.  If you’re like me you may want to know a useful way to take them out.  Easily.  Well check this out, here’s we will be using Dreamweaver CS4′s find-and-Replace tool to remove unnecessary blank lines between your code.   This is particularly helpful when there are a ton a blank lines in between each bit of your code.

Remove the Blank Lines from Your Code Files with Find and Replace Tools

How to Remove Unnecessary Lines Between Code

1. Open Dreamweaver (I am using CS4 for this tutorial).

In Dreamweaver CS4 Open a File

2. Next, what you’re going to want to do (and hopefully already have… is a piece of code (html, css, php, etc.) with a lot of lines that you want to replace.

File Tree Structure

3. Hit CTRL-F to open the Find-and-Replace tool

Find and Replace tool CTRL-F

4. Click the “use regular expression” checkbox

Click the Use Regular Expression Checkbox

5. Ensure the Search drop-down shows “Search Source Code

Search in Source Code

6. Copy-and-Paste ‘[\r\n]{2,}’ in the Find textarea (please notice the brackets have been taken out of the example shown here!”

Type "[\r\n]{2,}" (without quotes) in "Find"

7.  Copy-and-Paste \n” in the Replace text box.

Replace with \n

8. Click the”Find Next” or “Find All” just to be sure this is working properly before you go straight into the “Replace All” Feature.

Find All, Replace, Replace All Buttons

Note: Dreamweaver is the IDE I am using for this tutorial.  Other programs, such as Visual Studio have similar find-and-replace tools and most likely will work the same in this usage.

Hope this helped everyone, I know it helps me often.  FYI I got this information from the great forums over at digital point here

Leave a comment!

Copy-and-Paste

Related posts:

  1. Nothing happens when launching Dreamweaver CS5 on Mac So I recently started using a Mac at work and with the Adobe Creative Suite 5 just released I was pretty excited. The new additions to CS5 are great and I can see that working with WordPress will be a lot more streamlined. Anyways, I ran into a frustrating issue that a lot of other [...]...
  2. Link separators for wp_list_pages() code snippet WordPress makes it very easy to dynamically create menus from pages and categories with the use of the function wp_list_pages() and wp_list_cats()... but what if you want to have separators in your menus? Here's a bit of code that will do just that: wp_list_pages Separators Please note: I got this code from Rares Comes (very [...]...
  3. GoDaddy WordPress Sites Infected by HolasionWeb Malicious Code Have you gotten calls from your clients hosted on GoDaddy about their WordPress site's being 'hacked'? Or perhaps this happened to you yourself. It seems there's a new report of thousands of WordPress sites being infected by malicious javascript inserted on their WordPress website. It's not everyday that WordPress gets 'hacked' by something/one.  Today one [...]...
  4. WordPress Fix: Attribute “role” is not a valid attribute I like to design websites that are W3C Compliant.  Your WordPress theme may require some tweaking to be valid.  One error I kept receiving was: Attribute "role" is not a valid attribute. Did you mean "frameborder" or "scrolling"?  I will show you how to correct this error.  Simply put, to correct the error we are [...]...
  5. How to remove the “title” column from a SharePoint list Have you asked yourself the question: How do I remove the 'title column' from a Sharepoint list?  It can be annoying trying to figure out how to remove this column from default lists.  Often, site admins want their audiences to click on "New Item" in a Sharepoint list and not have to fill out the [...]...
  • http://www.3hvirtualservices.com Michelle Hutter

    Awesome tip! THANK YOU!

  • http:/www.dlocc.com Devin Walker

    Glad to help!