atom-editor - 我总是以 Atom 中的混合行尾结尾
问题描述
我安装了一个包(行尾选择器),它可以告诉我文件中使用了哪些行尾(LF 或 CRLF 或混合)。
默认情况下它是 LF(这是我的首选),但在编辑过程中它有时会变成混合,然后我总是必须手动将其设置回 LF。
当我忘记将所有行尾设置回 LF 时,这非常烦人,将文件以混合行尾推送到 Github,有人拉它,推送他们的更改,而提交的一半只是他们的编辑器所做的行尾更改该文件,因为它具有自动行尾更正 - 不像我的。
Atom 也可以有这个功能吗?有没有办法确保(例如在保存时)文件的所有行尾都设置为 LF?
解决方案
您可以使用.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 用户文档:处理行尾
或者,您可以使用EditorConfig来实现相同的目的。在团队或开源贡献者之间强制执行一致的设置特别有用。
推荐阅读
- flutter - 如何将文件 java.exe 更改为 keytool.exe,以便我可以为颤振创建签名的 apk?
- java - 如何使用 ArrayList 字段迁移 Room 数据库?
- javascript - 搜索不区分大小写
- reactjs - `props.children` 中的换行符
- time - 熊猫:groupby中的时差
- mysql - 在时间戳列上创建索引
- mysql - 在 mysql where, cast() str_to_date() 和 varchar 哪个更快更好,为什么
- neural-network - 使用 Gumbel Softmax 对中间层进行阈值处理
- php - 如何使用 CURRENT_TIMESTAMP 添加截止日期?
- angular - 如何在对象数组中分配对象?