如何在 Visual Studio (Express) 2008 中强制使用 Unix (LF) 行结尾?

发布于 2024-07-04 23:32:31 字数 62 浏览 7 评论 0原文

有没有办法在 Visual Studio 中始终使用 LF 行结尾? 我似乎永远找不到它!

Is there a way to always have LF line endings in Visual Studio? I can never seem to find it!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

最佳男配角 2024-07-11 23:32:31

您不必安装任何插件。
正如此处所述,您可以在 中配置行结尾文件-> 高级保存选项...

You don't have to install any plugins.
As mentioned here you can configure line endings in File -> Advanced Save options...

梦途 2024-07-11 23:32:31

Visual Studio 2008 有一个加载项,可以在保存文件时转换行尾格式。 您可以在这里下载:http://grebulon.com/software/stripem.php

There'a an add-in for Visual Studio 2008 that converts the end of line format when a file is saved. You can download it here: http://grebulon.com/software/stripem.php

黯然#的苍凉 2024-07-11 23:32:31

是的,有一种方法可以始终使用 LF 行结尾,至少在 Visual Studio 2010 Pro 中是这样。

转到工具| 选项... | 环境 | Documents

然后启用加载时检查行结尾是否一致选项。

这个对我有用。

Yes, there is a way to always have LF line endings, at least in Visual Studio 2010 Pro.

Go to Tools | Options... | Environment | Documents

Then Enable the Check for consistent line endings on load option.

It works for me.

青春有你 2024-07-11 23:32:31

我似乎偶然发现了一个方法,并发现这篇文章试图纠正它(我想要 Windows CRLF EOL)! 对我来说,执行以下操作会产生 UNIX(仅限 LF)行结尾。

SaveFileDialog^ dialog = gcnew SaveFileDialog();
System::Windows::Forms::DialogResult DR;
dialog->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
dialog->FilterIndex = 2;
dialog->RestoreDirectory = true;
dialog->DefaultExt = "txt";
DR = dialog->ShowDialog(this);
if ( DR == System::Windows::Forms::DialogResult::OK )
{
    // Get the page (tab) we are currently on
    System::Windows::Forms::TabPage ^selPage = this->tabControl1->SelectedTab;

    // Note: technically the correct way to look for our control is to use Find and search by name
    // System::Windows::Forms::RichTextBox ^selText = selPage->Controls->Find("rtb", false);
    // I only add one control (rich text) so first control ([0]) must be it
    System::Windows::Forms::RichTextBox ^selText = safe_cast<System::Windows::Forms::RichTextBox^>(selPage->Controls[0]);

    // Just let a Windows forms method do all the work
    File::WriteAllText(dialog->FileName, selText->Text);
}

I seem to have found a method by accident and found this article attempting to correct it (I want Windows CRLF EOL)! Doing the following results in UNIX (LF only) line endings for me.

SaveFileDialog^ dialog = gcnew SaveFileDialog();
System::Windows::Forms::DialogResult DR;
dialog->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
dialog->FilterIndex = 2;
dialog->RestoreDirectory = true;
dialog->DefaultExt = "txt";
DR = dialog->ShowDialog(this);
if ( DR == System::Windows::Forms::DialogResult::OK )
{
    // Get the page (tab) we are currently on
    System::Windows::Forms::TabPage ^selPage = this->tabControl1->SelectedTab;

    // Note: technically the correct way to look for our control is to use Find and search by name
    // System::Windows::Forms::RichTextBox ^selText = selPage->Controls->Find("rtb", false);
    // I only add one control (rich text) so first control ([0]) must be it
    System::Windows::Forms::RichTextBox ^selText = safe_cast<System::Windows::Forms::RichTextBox^>(selPage->Controls[0]);

    // Just let a Windows forms method do all the work
    File::WriteAllText(dialog->FileName, selText->Text);
}
红尘作伴 2024-07-11 23:32:31

关闭解决方案后,Visual Studio 2008 不会保留高级保存选项。 我愿意手动编辑大量文件,如果这样可以使其工作一致,但我不愿意每次打开 VS 时都更改所有设置。

这太糟糕了。 由于 VS 确实支持将行结尾强制为后端所需的任何内容,因此它只是没有在 UI 中正确连接。 也许微软会通过一个服务包来解决这个问题。

Visual Studio 2008 doesn't retain the advanced save options after the solution is closed. I would be willing to hand edit a lot of files if that would make it work consistently, but I am not willing to change all of the settings every time I open VS.

This is too bad. Since VS does support forcing the line-endings to whatever is desired in the backend, its just not hooked up properly in the UI. Maybe Microsoft will fix this isn a service pack.

凉栀 2024-07-11 23:32:31

VS 有一个名为 Strip'Em 的插件,您可以在其中选择保存时将所有行结尾自动转换为哪种新线型。

(您可以在 LF、CRLF、CR 之间进行选择。)

There's a plugin to VS called Strip'Em where you can choose which kind of new line type you want to auto convert all the line endings to when saving.

(You can choose between LF, CRLF, CR.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文