代码之家  ›  专栏  ›  技术社区  ›  tom

我总是以原子的混合线结尾

  •  0
  • tom  · 技术社区  · 7 年前

    我安装了一个程序包( Line Ending Selector )它可以告诉我文件中使用了什么行尾(lf、crlf或mixed)。

    默认情况下,它是lf(这是我的首选),但在编辑过程中,它有时会变得混合,然后我总是必须手动将其设置回lf。

    当我忘记将所有行尾设置回lf、将文件推到带有混合行尾的Github上、有人拉它、推它们的更改时,这是非常烦人的,并且其中一半提交内容只是行尾更改,它们的编辑器对该文件所做的更改是因为它具有自动行尾更正功能——而不像我的。

    Atom也可以有这个功能吗?是否有方法确保(例如在保存时)文件的所有行尾都设置为lf?

    2 回复  |  直到 7 年前
        1
  •  0
  •   idleberg    7 年前

    你可以利用 .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 达到同样的效果。在团队或开源贡献者之间强制实施一致的设置尤其有用。

        2
  •  0
  •   tom    7 年前

    我找到一个包裹( Force Line Endings )这正是我需要的。我想知道为什么其他人没有同样的问题,为什么这个软件包的下载量如此之少。

    推荐文章