visual-studio 在 Visual Studio 2010 中规范化行尾

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3406897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:18:49  来源:igfitidea点击:

Normalizing line endings in Visual Studio 2010

visual-studiovisual-studio-2010line-endings

提问by Jason

We have multiple developers working on an application and it seems that whenever one particular person works on a file then anyone else works on it they will get:

我们有多个开发人员在开发一个应用程序,似乎每当一个特定的人处理一个文件时,其他人都会得到:

The line endings in the following file are not consistent. Do you want to normalize the line endings?

以下文件中的行尾不一致。你想规范化行尾吗?

Is there some option in Visual Studio that we can have that developer change so we don't continually have this very irritating message pop up all the time?

Visual Studio 中是否有一些选项可以让开发人员更改,这样我们就不会一直弹出这个非常恼人的消息?

回答by Aaron Marten

If you don't want Visual Studio to check this when it opens the file, you can uncheck the box when prompted ("Always show this dialog") or in Tools->Options under Environment->Documents-> "Check for consistent line endings on load"

如果您不希望 Visual Studio 在打开文件时检查此项,您可以在出现提示时取消选中该框(“始终显示此对话框”)或在工具-> 环境下的选项-> 文档->“检查一致的行加载结束”

Someone on your project is probably using an editor that uses Unix-style or Mac-style line endings.

您项目中的某个人可能正在使用使用 Unix 风格或 Mac 风格行尾的编辑器。

回答by romaroma

It appears that Visual Studio preserve line endings when you copy/paste code from other sources. It means that even if you work alone on one platform you can get those annoying warnings.

当您从其他来源复制/粘贴代码时,Visual Studio 似乎会保留行尾。这意味着即使您单独在一个平台上工作,您也会收到那些烦人的警告。

We recently had mixed Mac and Windows line endings in a script after some code copy/paste from other project.

在从其他项目复制/粘贴一些代码之后,我们最近在脚本中混合了 Mac 和 Windows 行尾。

The issue was solved through copying the whole mixed code into a proper text-editor which was Notepad++. We then copied the text from Notepad++ and replaced text in Visual Studio. The resulting text had unified line endings.

这个问题是通过将整个混合代码复制到一个适当的文本编辑器中解决的,它是 Notepad++。然后我们从 Notepad++ 复制文本并在 Visual Studio 中替换文本。生成的文本具有统一的行尾。

回答by scottshelton

I've gotten this message before ( usually working with Unity3D and using VS2012 as my compiler ). The easiest way I've found to take care of the issue is to let VS format the code ( CTRL-K, CTRL-D ) and then save it.

我之前收到过这条消息(通常使用 Unity3D 并使用 VS2012 作为我的编译器)。我发现解决这个问题的最简单方法是让 VS 格式化代码( CTRL-K, CTRL-D ),然后保存它。

回答by Peter Y

If you are using version control then make sure that the server and client configurations for line endings are consistent with the way people are working and the server should be able to handle it properly.

如果您使用版本控制,那么请确保行尾的服务器和客户端配置与人们的工作方式一致,并且服务器应该能够正确处理它。

Eg for Perforce: http://kb.perforce.com/?article=063

例如 Perforce:http: //kb.perforce.com/?article= 063

Eg for Subversion, use svn:eol-style property http://svnbook.red-bean.com/en/1.7/svn.advanced.props.file-portability.html#svn.advanced.props.special.eol-style

例如对于 Subversion,使用 svn:eol-style 属性 http://svnbook.red-bean.com/en/1.7/svn.advanced.props.file-portability.html#svn.advanced.props.special.eol-style