How do I switch between Windows and UNIX newlines in Netbeans?

后端 未结 9 1466
执笔经年
执笔经年 2021-02-07 03:52

The version of NetBeans that I use is 6.5.1

相关标签:
9条回答
  • 2021-02-07 04:34

    There is a platform specific property that you may use make your code cross platform. See http://java.sun.com/docs/books/tutorial/deployment/applet/properties.html

    String newline = System.getProperty("line.separator");

    0 讨论(0)
  • 2021-02-07 04:43

    Please use this netbeans plugin

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

    0 讨论(0)
  • 2021-02-07 04:47

    I don't know how to do this using NetBeans, but if you store your code in a Subversion repository, you might want to look into the svn property svn:eol-style.

    0 讨论(0)
  • 2021-02-07 04:48

    There is a plugin that will help to switch the line endings. It is 'Show and change line endings'. You can install it directly within NetBeans.

    Go to Tools->Plugins->Available Plugins
    Then search for it. Check the checkbox and press 'Install' button.

    0 讨论(0)
  • 2021-02-07 04:48

    What is your goal - to have a work flow using only Unix line-endings?

    As has already been pointed out - there isn't any functionality in Netbeans to convert from one line ending to the other.

    New PHP files created in NetBeans (File > New File > PHP) have Unix line endings by default.

    This doesn't really give you the functionality you asked about but Netbeans will respect the file endings of existing files and create new PHP files with Unix line endings.

    0 讨论(0)
  • 2021-02-07 04:50

    Quoted from the Netbeans Wiki:

    NetBeans editor respects the line separator used in an existing file. It reads the file into an editor document instance in the following way:

    • First line of the file is read and the line separator type is determined - it is expected to be one of

      • "\n" (LF)- Unix
      • "\r" (CR)- Mac
      • "\r\n" (CRLF) - Windows
    • The line separator type is remembered in the document instance for future save operation.

    • All the lines in the file are read and their line separator (regardless of what type it is) is translated to "\n" that is the only line separator type that the editor is able to work with.
    • Upon save operation each "\n" in the document is translated into the remembered line separtor type.

    Note: If there would be a mixture of line separators of multiple types throughout the file then only the line separator type from the original first line will be used upon save.

    For new files (constructed from templates) the editor uses platform-default line separator.

    Update:

    As of Netbeans 7.3 there is a new change-line-endings-on-save plugin that allows you to configure line endings globally or per-project.

    0 讨论(0)
提交回复
热议问题