Visual Studio 的评论重花

发布于 2024-08-13 06:18:34 字数 234 浏览 2 评论 0原文

是否有内置命令或工具可以在 Visual Studio 中重排 C# 注释?

有时,一段代码需要多行注释,经过大量编辑后,您必须在适当的位置手动插入换行符,以免它超出编辑器窗口的右边缘。我希望能够通过一个键命令来完成此操作。

使用 Visual Studio 多年后,我仍然怀念 emacs 中 Mq(c-fill-paragraph)的功能。

编辑:Agent Smith 插件不会回流方法主体中的注释。

Is there a built-in command or tool that can reflow C# comments in Visual Studio?

Sometimes, a section of code requires several lines of comments, and after extensive editing you have to manually insert the line breaks in the appropriately places so that it does not flow past the right edge of your editor window. I'd like to be able to do this with a single key command.

After many years of using Visual Studio I still miss the ability to M-q (c-fill-paragraph) in emacs.

Edit: The Agent Smith plugin does not reflow comments in the method body.

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

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

发布评论

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

评论(4

谢绝鈎搭 2024-08-20 06:18:34

当我还是一名 Visual C++ 开发人员时,我编写了一个相当可配置的注释格式化工具,称为 Comment Reflower。此后我更换了平台,因此停止了移植,但幸运的是 Christoph Nahr 在 http://www 上保持了它的活力.kynosarges.de/CommentReflower.html

Back when I was a Visual C++ Developer I wrote a fairly configurable comment formatting tool called Comment Reflower. I have since changed platforms and so stopped doing ports, but thankfully Christoph Nahr has kept it alive at http://www.kynosarges.de/CommentReflower.html

南笙 2024-08-20 06:18:34

如果您想通过一次按键获得近乎完美的评论合理性,请使用评论重花

适用于 VS2012VS2013VS2015

VS2012:安装/升级 Visual Studio 2012 的 Comment Reflower

更新 2015-08-31:现在有一个 Comment Reflower 扩展可在扩展库中找到,可以直接从 Tools > 轻松安装。 VS2012、VS2013 和 VS2015 中的扩展和更新

  1. http://www.kynosarges.de/CommentReflower.html,解压到目录C:\Program Files (x86)\Visual Studio Comment Reflower


  2. 更新文件 CommentReflower.Addin,使 Version10.0 递增到 11.0(这会将其从 VS2010 升级)到 VS2012)。注意:此 .xml 文件中有两个点,您必须在其中更新此版本。

  3. 在 VS2012 中,选择Tools..Options..AddIn Security 并添加路径C:\Program Files (x86)\Visual Studio Comment Reflower

  4. 重新启动VS2012。

  5. 现在有新的菜单项:Tools..Reflow Comment at CursorTools..Comment Reflower Settings

VS2013:安装/升级 Visual Studio 2013 的 Comment Reflower

更新 2015-08-31:现在扩展库中提供了 Comment Reflower 扩展,可以直接从 Tools > 轻松安装。 VS2012、VS2013 和 VS2015 中的扩展和更新

重复上述说明,并将步骤 2 中的版本从 11.0 更改为 12.0

VS2015:安装/升级 Visual Studio 2015 的 Comment Reflower

现在有一个 Comment Reflower 扩展直接从 Tools > 轻松安装的扩展库VS2012、VS2013 和 VS2015 中的扩展和更新

感谢@Martin Liversage 指出了这一点。

要添加一个快捷键来调整光标所在的当前注释

  1. 转到工具..选项..键盘,在显示命令中键入reflow,其中包含,选择CommentReflower.Connect.ReflowPoint,在按快捷键框中键入组合键(例如Ctrl-J),然后点击分配

  2. 现在,如果您将光标放在评论上,然后按所述组合键 (Ctrl-J),它会自动(并且精美地)为您证明该评论的合理性。您应该会看到绑定键出现在 Tools 菜单中:

在此处输入图像描述

更新边距宽度

进入 Tools..Comment Reflower Settings 并将 Wrap Width 从默认值 80 更改为更宽的值,例如 140,并且“最小块宽度”为 10*不要* 将其设置为更小的值!):

在此处输入图像描述

If you want near perfect comment justification with a single keystroke, use Comment Reflower.

Works with VS2012, VS2013 and VS2015.

VS2012: To install/upgrade Comment Reflower for Visual Studio 2012

Update 2015-08-31:There is now a Comment Reflower extension available in the extension gallery that easily installs directly from Tools > Extensions and Updates in VS2012, VS2013 and VS2015.

  1. Download "Comment Reflower" from http://www.kynosarges.de/CommentReflower.html, unzip into the directory C:\Program Files (x86)\Visual Studio Comment Reflower.

  2. Update file CommentReflower.Addin so that Version increments from 10.0 to 11.0 (this upgrades it from VS2010 to VS2012). NOTE: There are two spots in this .xml file where you have to update this version.

  3. In VS2012, select Tools..Options..AddIn Security and add the path C:\Program Files (x86)\Visual Studio Comment Reflower.

  4. Restart VS2012.

  5. Now there is new menu items: Tools..Reflow Comment at Cursor and Tools..Comment Reflower Settings.

VS2013: To install/upgrade Comment Reflower for Visual Studio 2013

Update 2015-08-31:There is now a Comment Reflower extension available in the extension gallery that easily installs directly from Tools > Extensions and Updates in VS2012, VS2013 and VS2015.

Repeat instructions above, and change the version in step 2 from 11.0 to 12.0.

VS2015: To install/upgrade Comment Reflower for Visual Studio 2015

There is now a Comment Reflower extension available in the extension gallery that easily installs directly from Tools > Extensions and Updates in VS2012, VS2013 and VS2015.

Thanks to @Martin Liversage for pointing this out.

To add a shortcut key that justifies the current comment your cursor is on

  1. Go to Tools..Options..Keyboard, type reflow in Show commands containing, select CommentReflower.Connect.ReflowPoint, type a key combination (e.g. Ctrl-J) in the box Press shortcut keys, then hit Assign.

  2. Now, if you position your cursor on a comment, and press said key combination (Ctrl-J), it will automatically (and beautifully) justify the comment for you. You should see the bound key appear in the Tools menu:

enter image description here

Update margin width

Go into Tools..Comment Reflower Settings and change the Wrap Width from the default of 80 to something wider, such as 140, and the "Minimum Block Width" to 10 (do *not* set it to anything smaller!):

enter image description here

小…楫夜泊 2024-08-20 06:18:34

如果您使用 ReSharper,可以使用免费的 Agent Smith 插件来回流评论。

If you are using ReSharper, there is the free Agent Smith plugin that can reflow comments.

这样的小城市 2024-08-20 06:18:34

如果您使用 ///// 样式注释 CodeMaid 对我来说非常有用。它是免费且开源的,我可以在 C++ 和 C# 中使用它。

If you use // or ///-style comments CodeMaid has worked great for me. It is free and open source, and I can use it in both C++ and C#.

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