How to convert Windows end of line in Unix end of line (CR/LF to LF)

后端 未结 8 771
臣服心动
臣服心动 2020-11-29 18:59

I\'m a Java developer and I\'m using Ubuntu to develop. The project was created in Windows with Eclipse and it\'s using the Windows-1252 encoding.

To convert to UTF-8

8条回答
  •  一向
    一向 (楼主)
    2020-11-29 19:19

    Actually, vim does allow what you're looking for. Enter vim, and type the following commands:

    :args **/*.java
    :argdo set ff=unix | update | next
    

    The first of these commands sets the argument list to every file matching **/*.java, which is all Java files, recursively. The second of these commands does the following to each file in the argument list, in turn:

    • Sets the line-endings to Unix style (you already know this)
    • Writes the file out iff it's been changed
    • Proceeds to the next file

提交回复
热议问题