?
Solved

fix source code in dreamweaver that is double spaced

Posted on 2009-07-01
16
Medium Priority
?
642 Views
Last Modified: 2012-05-07
I have some scripts that keep getting double spaced due to someone elses FTP program. I have asked them to stop using it but it's already affected many files and it's too late to go back into the old versions of the code because we've committed these spaces to our repository due to time restrictions.

How can I single space the file easily in dreamweaver. I'm willing to use another utility if necessary.
0
Comment
Question by:MeridianManagement
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
  • +2
16 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757752
Hi MeridianManagement,

You can do Commands | Apply Source Formatting to fix excessive whitespace.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24757761
doesn't seem to fix php...
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757809
Hmph, it apparently doesn't.  Are these pages just PHP code or mixed PHP and HTML?

0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 2

Author Comment

by:MeridianManagement
ID: 24757813
mixed. There is also a lot of javascript files with the same issue.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757856
Okay.

The reason this happened is that the other user has a different line-break method set than you do.    DW probably isn't the best tool for this because you would need to run a Find and Replace on two blank lines in Source Code mode and I can see that not working as expected.

Go grab NotePad++ as it has an option to remove blank lines under its TextFX | TextFX Edit menu.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24757883
Thanks Jason,

That's definitely a pretty close solution. I was hoping it would be possible to only replace every other line (not everyone empty line), because technically there are some line breaks for a reason. If you can think of anything let me know
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757931
You can apply the Notepad++ solution selectively.  So highlight the code that has the excessive line breaks and apply the TextFX.  It will only remove the line breaks from the selected area.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24758952
MeridianManagement,

This might be something where a Regex could help too.  Does Notepad++ support those for a replace?   Can you provide a sample file so I can make sure I understand how the file is affected?  If Notepad++ won't work with a Regex then there are other programs that will although I am not sure of free ones that you can use.  I believe there are some but I would have to verify first.

The PSPad editor has a number of features too so it might also have an option to strip the extra lines and not be bothered by PHP.  Let me know if you want me to test and verify this but a sample file will help this.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24758960
b0lsc0tt,

Good points.  NotePad++ does support regex, as does DW but DW's regex interpreter is a little limited.

0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24759017
If so, and without a sample to be sure, then you would need some a regex like the following for the test ...
\r\n\r\n
... and then in the replace you just provide a line break (i.e. hit the Enter key probably although I can provide characters if the program can convert them).
The thing I don't know for sure is if the file that is being read wrong actually has a carriage return and a new line character or just the new line character.  Most likely the former.  I have seen files "messed up" like this before but never bothered to spend the time to see why or try to fix them.  Homesite just corrects them in the display but it is annoying to have them messed up.
A sample will really help.  Also if you have a question trying to use the above then let me know about the program and choices you see.
bol
0
 
LVL 5

Expert Comment

by:Opalelement
ID: 24760943
If you replace two newlines with one newline in dreamweaver find&replace, it should only take out every other line
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24765420
Opalelement,

That may or may not work as expected.  If another user opens the file in a different editor you may get different types of line breaks.  That's why b0lsc0tt suggested regex and I suggested Notepad++ because those options can handle \n\n \n\r or \r\n depending on how the other editor threw those in.  DW will handle a blank line in Find and Replace differently depending on which line break type is chosen in the options.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24766001
okay here's an example of a file. It was partially fixed in dreamweaver that's why some of the file looks okay.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24766022
Here you go, it didn't like the php extension
property-display.txt
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 2000 total points
ID: 24766189
It is the \r\n that is used (i.e. a carriage return followed by the new line character).  In the match field (or its equivalent) use ...
\r\n\r\n
... and in the replace field you would either place ...
\r\n
... or just press Enter.  Now that will get rid of every occurence, except 4 in the case of your file above.  In that file it looks like 4 lines already had the double space so they actually have 3 line breaks now.  You could run it again if you want to get rid of them all but maybe you want to keep those.
Let me know how it works.  If Dreamweaver has a problem then I used a program called EditPad (actually the Pro version) to run it and it worked.  Let us know if you have a question.
bol
0
 

Expert Comment

by:m_abdelfattah
ID: 25290639
This should be the solution :
1. Open Dreamweaver Preferences ( Edit -> Preferences ).
2. Select Code Format
3. Change Line break type to LF (UNIX)
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question