visual-studio 如何让 Visual Studio 在 80 个字符处换行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/236517/
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 09:48:51  来源:igfitidea点击:

How can I make Visual Studio wrap lines at 80 characters?

visual-studio

提问by JosephStyons

Is there any way to make Visual Studio word-wrap at 80 characters? I'm using VS2008.

有没有办法让 Visual Studio 自动换行 80 个字符?我正在使用 VS2008。

This post is loosely related.

这篇文章是松散相关的。

采纳答案by TGnat

Tools >> Options >> Text Editor >> All Languages >> General >> Select Word Wrap.

工具>>选项>>文本编辑器>>所有语言>>常规>>选择自动换行。

I dont know if you can select a specific number of columns?

不知道您是否可以选择特定数量的列?

回答by Igal Tabachnik

Unless someone can recommend a free tool to do this, you can achieve this with ReSharper:

除非有人可以推荐免费工具来执行此操作,否则您可以使用ReSharper实现此目的:

ReSharper >> Options... >> Languages/C# >> Line Breaks and Wrapping

ReSharper >> 选项... >> 语言/C# >> 换行符和换行

  • Check "Wrap long lines"
  • Set "Right Margin (columns)" to the required value (default is 120)
  • 选中“换行长线”
  • 将“右边距(列)”设置为所需值(默认为 120)

Hope that helps.

希望有帮助。

回答by Stewart Johnson

I don't think you can make VS wrap at 80 columns (I'd find that terribly annoying) but you can insert a visual guideline at 80 columns so you know when is a good time to insert a newline.

我不认为你可以让 VS 在 80 列处换行(我觉得这很烦人)但是你可以在 80 列处插入一个视觉指南,这样你就知道什么时候是插入换行符的好时机。

Details on inserting a guideline at 80 characters for 3 different versions of visual studio.

有关为 3 个不同版本的 Visual Studio 插入 80 个字符的指南的详细信息

回答by Cory Koch

You can also use

你也可以使用

Ctrl+E, Ctrl+W

Ctrl+E, Ctrl+W

keyboard shortcut to toggle wrap lines on and off.

打开和关闭换行的键盘快捷键。

回答by idbrii

To do this with Visual Assist(another non-free tool):

要使用Visual Assist(另一个非免费工具)执行此操作:

VAssistX >> Visual Assist X Options >> Advanced >> Display

VAssistX >> Visual Assist X 选项 >> 高级 >> 显示

  • Check "Display indicator after column" and set the number field to 80.
  • 选中“在列后显示指示器”并将数字字段设置为 80。

回答by idbrii

Adds vertical column guides to the Visual Studio text editor. This version is for Visual Studio 2012, Visual Studio 2013 or Visual Studio 2015.

向 Visual Studio 文本编辑器添加垂直列指南。此版本适用于 Visual Studio 2012、Visual Studio 2013 或 Visual Studio 2015。

See the plugin.

查看插件。

回答by Corio

I stumbled upon this question when was actually searching for an answer to this one(how to add a visual line/guideline at char limit). So I would like to leave a ref to it here for anyone like myself.

我偶然发现了这个问题时,实际上是寻找一个答案,这个(如何添加在焦炭限视线/准则)。所以我想在这里为像我这样的人留下一个参考。

回答by HelloGoodbye

If the problem is simply that you want to know when you pass 80 characters for a single line, which is a common coding guideline limit, you can use a different approach: Editor Guidelines. This will add vertical column guides behind your code.

如果问题只是您想知道何时为单行传递 80 个字符,这是常见的编码指南限制,您可以使用不同的方法:Editor Guidelines。这将在您的代码后面添加垂直列指南。

回答by Charbel.AY

code --> preferences --> settings --> text editor --> scroll down until you see word wrap set it to wordWrapColumn --> under Word Wrap Column insert the number of characters you want to be on a line

代码 --> 首选项 --> 设置 --> 文本编辑器 --> 向下滚动,直到看到自动换行将其设置为 wordWrapColumn --> 在自动换行列下插入要在一行中显示的字符数

enter image description here

在此处输入图片说明

回答by Roland Pihlakas

See also this answerin order to switch the mode conveniently.

另请参阅此答案以方便地切换模式。

Citation:

引文:

I use this feature often enough that I add a custom button to the command bar.

Click on the Add or Remove -> Customize
Click on the Commands tab
Select Edit|Advanced from the list
Find Toggle Word Wrap and drag it onto your bar

我经常使用这个功能,以至于我向命令栏添加了一个自定义按钮。

单击添加或删除 -> 自定义
单击命令选项卡
从列表中选择编辑|高级
查找切换自动换行并将其拖到您的栏上