22

Netbeans has this wiki entry on line endings: http://wiki.netbeans.org/FaqEditorEOLs

But it isn't very useful. It just says that you shouldn't develop on different OS and that's that...

In my situation however, I have no power over it. I'm on a windows machine and the PHP app I'm working on needs to end with the UNIX EOL.

There does not seem to be an option to set this for new files. Can anyone tell me where to set this?

Stefano
  • 18,083
  • 13
  • 64
  • 79
KdgDev
  • 14,299
  • 46
  • 120
  • 156

6 Answers6

14

Just saw that you can set this as a command-line startup flag: -J-Dline.separator=LF

I haven't tested this myself but I'm looking for ways to bake this into the configs somehow.

fentie
  • 268
  • 2
  • 2
13

Since, a specific plug-in came out: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=36810

I also like @JimLewis suggestion but I work on Windows with a linux virtual machine thus in some cases the versioning system line ending cannot help.

[update 201709]

I no longer use netbeans (sorry, but I need python support and it's too buggy) and almost no longer develop on windows, but @marinos-an in a comment suggests https://github.com/welovecoding/editorconfig-netbeans which uses a common setting file that can be picked up by multiple editors through plugins. Definitely interesting to try since the settings file is committable!

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
Stefano
  • 18,083
  • 13
  • 64
  • 79
  • 2
    This plugin works perfectly - it adds the current setting to the status bar and allow you to change by clicking on it – Deebster Jul 26 '12 at 11:42
  • ...and by the way, my current experience with line ending on the borderline world of windows with a linux virtual machine is that it's better to force LF everywhere. Windows knows how to deal with it, in any case (beside notepad that shouldn't even exist). – Stefano Jan 29 '13 at 10:31
  • This is an important issue, I really can't figure out why such a feature is not implemented natively into Netbeans. It's not that hard to do and it's very useful. The plugin works perfectly, btw, thanks. – Radu Murzea Apr 27 '13 at 17:48
  • This plugin https://github.com/welovecoding/editorconfig-netbeans may be even more useful, since it can be used to **force** line-ending rules, and supports a kind of standardized committable format: http://editorconfig.org (which has a wide editor support: https://github.com/editorconfig/). – Marinos An Sep 21 '17 at 12:23
  • I confirm it is working fine for Netbeans 8.2 (development version Build 201804200002 ) – Yevgeniy Afanasyev Sep 17 '18 at 00:49
11

Have you considered managing the line endings at the version control level? Subversion, for example, lets you set an "eol-style" attribute with values "LF", "CR", "CRLF", and "native" (which translates the line endings stored in the repository to whatever is appropriate for the platform where the files are being checked out, and converts the other way when you check in.)

Jim Lewis
  • 43,505
  • 7
  • 82
  • 96
  • 2
    The OP did not say anything about using version control software, but I do agree with setting this property in a `.gitattributes` file or whatever it is for your VCS. – rink.attendant.6 Sep 25 '13 at 16:07
  • +1 ... and simple procedure for git: https://help.github.com/articles/dealing-with-line-endings – Karussell Jan 11 '14 at 23:33
  • 1
    @rink.attendant.6 Netbeans does not seem to correctly support `.gitattributes`. It uses JGit behind the scenes: https://bugs.eclipse.org/bugs/show_bug.cgi?id=342372 (chaotic) . I has struggling to findout why some sometimes newlines were added as CRLF and sometimes they weren't. It depended on whether Netbeans was used to add the files or the git cli. – Marinos An Sep 21 '17 at 12:06
2

Please use following Netbeans Plugin

http://plugins.netbeans.org/plugin/36810/show-and-change-line-endings

Mudaser Ali
  • 3,989
  • 3
  • 25
  • 27
2

fentie's answer solved my problem with line endings, as pasting multi-line MySQL from NetBeans into the MySQL command prompt caused errors.

To pass this argument to NetBeans every time it opens, add it to the netbeans.conf file:

/Applications/NetBeans/NetBeans\ 7.1.2.app/Contents/Resources/NetBeans/etc/netbeans.conf on OS X.

From the NetBeans Mac page under Tips & Tricks.

When I pasted multi-line SQL statements from NetBeans to the MySQL command line client on OS X or a remote Linux server, MySQL would list all possible command choices, give me some strange '> type of prompt and I was forced to hit Ctrl+C and log back into MySQL again.

Brent Self
  • 373
  • 2
  • 5
0

For my Netbeans 12.6

I found a pluging called "Change Line Endings on Save"

https://plugins.netbeans.apache.org/catalogue/?id=31

more details are there

https://github.com/junichi11/netbeans-change-lf

once pluging installed you can configure EOL in there:

Tools > Options > Editor > Line Endings

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191