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

时间:2023-01-14 18:38:52

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

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

8 个解决方案

#1


7  

Hope this article will help you:

希望本文能为您提供帮助:

How To Save a File from Visual C++ in UNIX Format

如何以UNIX格式从Visual C ++保存文件

Unfortunately it seems to be the only way to save files in Unix format by default.

不幸的是,它似乎是默认情况下以Unix格式保存文件的唯一方法。

Personally I use Advance Save option in Save File dialog. But to be hones I never have a need to work with large number of files in Unix format from MSVS.

我个人在保存文件对话框中使用高级保存选项。但要成为hones,我从来不需要使用MSVS的Unix格式的大量文件。

#2


72  

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

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

#3


7  

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

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

#4


4  

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

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

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

转到工具|选项...... |环境|文件

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

然后启用“检查加载时一致的行结束”选项。

It works for me.

这个对我有用。

#5


1  

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.

解决方案关闭后,Visual Studio 2008不会保留高级保存选项。我愿意手动编辑很多文件,如果这样可以使它一致地工作,但我不愿意每次打开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.

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

#6


0  

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.

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

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

(您可以选择LF,CRLF,CR。)

#7


0  

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.

我似乎偶然发现了一种方法,发现这篇文章试图纠正它(我想要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);
}

#8


0  

Tools / Options / Text Editor / C# / IntelliSense change "Enter key behavior:" to "Always add new line on enter"

工具/选项/文本编辑器/ C#/ IntelliSense更改“输入键行为:”到“始终在输入时添加新行”

#1


7  

Hope this article will help you:

希望本文能为您提供帮助:

How To Save a File from Visual C++ in UNIX Format

如何以UNIX格式从Visual C ++保存文件

Unfortunately it seems to be the only way to save files in Unix format by default.

不幸的是,它似乎是默认情况下以Unix格式保存文件的唯一方法。

Personally I use Advance Save option in Save File dialog. But to be hones I never have a need to work with large number of files in Unix format from MSVS.

我个人在保存文件对话框中使用高级保存选项。但要成为hones,我从来不需要使用MSVS的Unix格式的大量文件。

#2


72  

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

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

#3


7  

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

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

#4


4  

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

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

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

转到工具|选项...... |环境|文件

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

然后启用“检查加载时一致的行结束”选项。

It works for me.

这个对我有用。

#5


1  

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.

解决方案关闭后,Visual Studio 2008不会保留高级保存选项。我愿意手动编辑很多文件,如果这样可以使它一致地工作,但我不愿意每次打开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.

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

#6


0  

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.

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

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

(您可以选择LF,CRLF,CR。)

#7


0  

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.

我似乎偶然发现了一种方法,发现这篇文章试图纠正它(我想要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);
}

#8


0  

Tools / Options / Text Editor / C# / IntelliSense change "Enter key behavior:" to "Always add new line on enter"

工具/选项/文本编辑器/ C#/ IntelliSense更改“输入键行为:”到“始终在输入时添加新行”