We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

fix source code in dreamweaver that is double spaced

Medium Priority
663 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.
Comment
Watch Question

Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
Hi MeridianManagement,

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

Author

Commented:
doesn't seem to fix php...
Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
Hmph, it apparently doesn't.  Are these pages just PHP code or mixed PHP and HTML?

Author

Commented:
mixed. There is also a lot of javascript files with the same issue.
Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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
Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
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.
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
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
Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
b0lsc0tt,

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

b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
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
If you replace two newlines with one newline in dreamweaver find&replace, it should only take out every other line
Jason C. LevineDon't talk to me.
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
okay here's an example of a file. It was partially fixed in dreamweaver that's why some of the file looks okay.

Author

Commented:
Here you go, it didn't like the php extension
property-display.txt
IT Manager
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
This should be the solution :
1. Open Dreamweaver Preferences ( Edit -> Preferences ).
2. Select Code Format
3. Change Line break type to LF (UNIX)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.