如何修复整个 VS 解决方案的不一致行尾? [英] How to fix inconsistent line endings for whole VS solution?

查看:24
本文介绍了如何修复整个 VS 解决方案的不一致行尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 将在打开文件时检测不一致的行结尾,并且有一个选项可以针对该特定文件修复它.但是,如果我想修复解决方案中所有文件的行尾,我该怎么做?

Visual Studio will detect inconsistent line endings when opening a file and there is an option to fix it for that specific file. However, if I want to fix line endings for all files in a solution, how do I do that?

推荐答案

为了更完整的答案,这对我来说效果最好:

Just for a more complete answer, this worked best for me:

替换

(?<!\r)\n

\r\n

在带有regEx"选项的整个解决方案中.

in entire solution with "regEx" option.

这将在迄今为止没有正确行尾的所有文件中设置正确的行尾.它使用负前瞻来检查 \n 前面是否不存在 \r.

This will set the correct line ending in all files which didn't have the correct line ending so far. It uses the negative lookahead to check for the non-existance of a \r in front of the \n.

注意其他解决方案:它们将修改所有文件中的所有行(忽略原始行结尾)或删除每行的最后一个字符.

Be careful with the other solutions: They will either modify all lines in all files (ignoring the original line ending) or delete the last character of each line.

这篇关于如何修复整个 VS 解决方案的不一致行尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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