我安装了一个软件包(Line Ending Selector),该软件包可以告诉我文件中使用了哪些行尾(LF或CRLF或Mixed)。
默认情况下,它是LF(这是我的首选),但是在编辑过程中,有时它会变成Mixed(混合),然后我总是必须手动将其设置回LF。
当我忘记将所有行尾设置为LF,将文件以混合行尾推送到Github上,有人将其拉出,推送其更改时,这很烦人,而一半的提交只是他们的行尾更改该文件具有编辑器,因为它具有自动的行尾更正功能-不同于我的。
Atom还能具有此功能吗?有没有办法确保(例如保存时)文件的所有行尾都设置为LF?
答案 0 :(得分:0)
我找到了一个完全可以满足我需要的软件包(Force Line Endings)。我不知道为什么其他人不会遇到同样的问题,为什么这个软件包下载量很少。
答案 1 :(得分:0)
您可以使用.gitattributes
处理行尾:
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
相关:GitHub User Documentation: Dealing with line endings
或者,您可以使用EditorConfig来达到相同的目的。在团队或开源贡献者之间实施一致的设置特别有用。