【问题标题】:How can I tell Visual Studio to rearrange my comments onto multiple lines?如何告诉 Visual Studio 将我的评论重新排列到多行?
【发布时间】:2016-01-24 05:37:48
【问题描述】:

有时当我在 Visual Studio 中评论我的代码时,我发现我的 cmets 拖到了我的其余代码之外。是否有任何快捷方式、方法或扩展可以将这些单行怪物重新排列为跨多行分布的格式良好的 cmets?格式化文档似乎不会影响 cmets。

比如说,我写了这么长的评论:

// If at this point the task has not completed it has exceeded the maximum time and a timeout exception should be thrown.

有什么简单的方法可以将其重新排列成类似以下的内容(除了手动)?

// If at this point the task has not completed it has exceeded the maximum
// time and a timeout exception should be thrown.

【问题讨论】:

  • 我认为这是不可能的。需要考虑的一件事是,代码中的 cmets 通常被认为是代码异味(一个坏主意)。您确实应该将代码重构为更小的方法并适当地命名方法以显示您的意图。
  • 谢谢@Andrew。我真的没有这么想过。 +1
  • 我建议您阅读 Robert C Martin 的一本书,名为“清洁代码”,它将改变您对编码的看法。

标签: c# visual-studio visual-studio-2015 keyboard-shortcuts


【解决方案1】:

CodeMaid 扩展包括 Comment Formatting 以在指定列处换行。

【讨论】:

  • 那个扩展看起来不错。谢谢谢尔盖!
猜你喜欢
  • 2015-10-29
  • 2010-12-22
  • 1970-01-01
  • 1970-01-01
  • 2019-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-31
相关资源
最近更新 更多