Discussion:
[NB-Editor] How to change line separator from "\n" to "\r\n"?
Patrick Wunderlich
2004-10-25 10:19:14 UTC
Permalink
Hello NB-Users,

i'm using Netbeans 3.6 on my Linux Machine.
Per default the Netbeans Editor uses "\n" as line separator.
But i want "\r\n" as line separator, because i often exachange
files (java, xml, ...) with windows users.

Any hints?

Regards,
Patrick
Wade Chandler
2004-10-25 16:37:30 UTC
Permalink
Post by Patrick Wunderlich
Hello NB-Users,
i'm using Netbeans 3.6 on my Linux Machine.
Per default the Netbeans Editor uses "\n" as line separator.
But i want "\r\n" as line separator, because i often exachange
files (java, xml, ...) with windows users.
Any hints?
Regards,
Patrick
What type of program are they using that is not able to view the files
correctly? Wordpad/Write.exe even views \n correctly. About the only
things that don't are crap text editors and notepad. For a pure text
editor I use Textpad on windows and Kate on linux.

Anyways, other than that:
In NB4.0 locate under the install dir the folder etc and in there
netbeans.conf. This will change the settings for the entire VM:
modify the property netbeans_default_options by adding this to the
current list(wrap white space around it):
-J-Dline.separator=\r\n

In 3.6 locate <nb install dir>/bin/ide.cfg and put that same line:
-J-Dline.separator=\r\n

on it's own line. That should work I guess for 3.6 though I haven't
tried it, but I assume it will be parsed by NB like a properties file
(escapes will be used that is).


Anyways, that should do it I think.

Wade
Patrick Wunderlich
2004-10-26 08:11:53 UTC
Permalink
Post by Wade Chandler
What type of program are they using that is not able to view the files
correctly? Wordpad/Write.exe even views \n correctly. About the only
things that don't are crap text editors and notepad. For a pure text
editor I use Textpad on windows and Kate on linux.
Long ago when i used windows i also used a good editor like ultraedit.
But some persons use windows and only the stupid notepad :(
Post by Wade Chandler
-J-Dline.separator=\r\n
I tried that, but it did not work :(

E.g. in jedit there is an option to set the line separator?!
Why not in Netbeans?
Tim Boudreau
2004-10-26 15:42:45 UTC
Permalink
Post by Patrick Wunderlich
Post by Wade Chandler
What type of program are they using that is not able to view the files
correctly? Wordpad/Write.exe even views \n correctly. About the only
things that don't are crap text editors and notepad. For a pure text
editor I use Textpad on windows and Kate on linux.
There are plenty of ways to end up in this situation - being emailed a
file from a different system, restoring a backup of sources from, say, a
mac on a windows machine, etc. Doesn't happen often, but it does happen.
Post by Patrick Wunderlich
Long ago when i used windows i also used a good editor like ultraedit.
But some persons use windows and only the stupid notepad :(
Post by Wade Chandler
-J-Dline.separator=\r\n
I tried that, but it did not work :(
E.g. in jedit there is an option to set the line separator?!
Why not in Netbeans?
I can't answer that, but I do have a feeling such a setting might cause
more problems than solutions - easy to set and forget, and there are
lots of tools (CVS, archiving utilities, etc.) which will make
assumptions about the line separator based on the platform - assumptions
that would be wrong in the case that an IDE was intentionally setting
the line separators to something other than the platform default (not to
mention that an IDE making wholesale changes to every line of a file
just because it was opened could cause serious wreckage, or at least
make a mess out of what someone was committing into version control).

There are quite a few of command line utilities which do this sort of
conversion. One a lot of people are quite likely to have is zip/unzip:

unzip -a auto-convert any text files
unzip -aa treat ALL files as text

So if you have a large number of files with this problem, the simplest
solution may just be to zip them on the command line and unzip them with
one or both of the above arguments.

-Tim

Continue reading on narkive:
Loading...