Vim:Mac与Linux ^ M问题 [英] Vim: Mac vs. Linux ^M Problem

查看:60
本文介绍了Vim:Mac与Linux ^ M问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Vim和GIT在Linux/Ubuntu机器上开发项目.过去,我曾经使用Windows,这意味着行尾是DOS格式.现在,转移到Linux后,我总是在行尾看到^ M个令人困惑/讨厌的字符.这里的一些人:

I use Vim and GIT to develop my project on a Linux/Ubuntu machine. In the past, I used to use Windows, which means line ends were DOS format. Now after moving to Linux, I always see ^M confusing/annoying characters at the end of the line. Some people here:

如何转换在 vim 中打开的文件中的 ^M 换行符到正常"换行符?

建议我应该查找/替换或使用诸如dos2unix之类的工具.这些都是不错的建议,但是对于一个版本控制的项目,这意味着我必须在更改后为文件添加不必要的提交,无论如何这都是一项艰巨的任务,不值得花时间在上面.所以:

suggested that I should make a find/replace or use tools like dos2unix. These are good suggestions, but with a version-controlled project it means I have to add unnecessary commits for the files after change, and it is a big task anyway that is not worth spending time on it. So:

是否有办法使Vim对此有所容忍?也就是说,如果文件是DOS行尾的,它将保持这种状态,并将其格式用于新的换行符,依此类推.

推荐答案

我发现最好的答案是评论中的@Keith答案:

The best answer I found is @Keith answer in the comments:

通过Subversion,您可以设置svn:eol-style = native属性,该属性将自动将行尾转换为所有平台的本机类型.我不知道git是否具有该功能,但是您可能首先检查一下.可能会的."

"With subversion you can set a property svn:eol-style=native that will cause it to convert line endings to.. native type for all platforms automatically. I don't know if git has that feature, but you might look into that first. It probably does."

这些链接可能有用的链接是如何设置的:
http://help.github.com/dealing-with-lineendings/
http://git-scm.com/docs/gitattributes

And these links might be useful link is how to set:
http://help.github.com/dealing-with-lineendings/
http://git-scm.com/docs/gitattributes

这篇关于Vim:Mac与Linux ^ M问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆