How to remove extra empty lines from file with mac line endings in VS 2008?

488 views Asked by At

So that's the question...perhaps there's a regular expression for this? Just to be clear, I don't want to remove ALL newlines and bunch all of the code together, only the extras. I'm not familiar with how to construct regexes, so any help is greatly appreciated!

And here's the explanation as to why:

I was obviously ignorant of the troubles the following situation could cause, so you know I'm now fully aware of that! I've submitted c# code on a mac to perforce, which originally came from windows. Now I've updated those source files on my PC, and their line endings are now messed up, with VS 2008 giving me a compiler error, telling me to fix my mac line endings. I found the Stripem VS add-in, which fixes the compile error, but the code looks terrible, with tons of extra lines.

2

There are 2 answers

1
DavidRR On

For the regex approach, see if you can match one or both of \r or \n .

0
Carnifex On

I don't know what ending of line mac's are using... but if it is \n and \r this could help:
remove all \r or replace it with \n, then replace multiple \n with one \n.

You could use Notepad++, it has nice conversion between EOL Windows/UNIX/Mac.

FYI: I use VS2012 and there is build-in mechanism for this kind of things:
File -> Advanced Save Option...
And then you choose encoding and line endings.