Visual Studio 是否有任何插件可以按照我喜欢的方式自动格式化代码?
当我打开任何代码文件时,无论是我编写的文件还是其他开发人员的文件,我希望它能够根据我的偏好自动格式化它,包括支撑、缩进、行距等。
理想情况下,将文件保存到磁盘时,它 会自动格式化它。只会保存我接触过的代码/行的格式。它仍然会显示格式化的其余代码,但是它不会将它们保存到磁盘(以免激怒其他开发人员)。
When I open any code file, whether something i've written or something from another developer, I want it to automatically format it with my preference of bracing, indentation, line spacing, etc..
Ideally, when saving a file to disk, it would only save the formatting for code/lines i've touched. It would still display the rest of the code formatted, however it would not save these to disk (so as to not piss off other developers).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Resharper 来实现此目的。它将显示格式不一致的警告(通过彩色下划线,很像拼写检查器的警告),并且您可以指示它根据默认格式规则或您自己的格式重新格式化所选内容或整个文件。
格式规则可自定义,以适应您自己的编码标准。
You could use Resharper for this. It will show warnings for formatting inconsistencies (via colored underscores, much like warnings for spellcheckers), and you could instruct it to reformat a selection or a whole file based on either the default formatting rules or your own.
Formatting rules are customizable to fit your own coding standards.
Visual Assist X 适用于 C/C++ 和 C#。每当我不幸需要在 Windows 中执行操作时,我都会广泛使用它:-)。
重构工具很棒。它修复了 Visual Studio 智能完成。事实上,当你使用 Visual Assist X 后,Visual Studio 智能补全看起来太垃圾了,你不会相信你为这种蹩脚的“智能”付出了这么多。
当然,Visual Assist X 还添加了急需的片段。当您在观看那些 Textmate 截屏视频时看到那些“特殊动作”片段时,您终于可以停止流口水了。
Visual Assist X works for both C/C++ and C#. I use it extensively whenever I have the unfortunate needs to do things in Windows :-).
The refactoring tool is awesome. It fixes Visual Studio smart completion. In fact, after you use Visual Assist X, Visual Studio smart completion looks so dump that you won't believe you paid so much for such crappy "smartness".
Of course, Visual Assist X also adds the much needed snippets. You can finally stop drooling when you see those snippet "special moves" when viewing those Textmate screencasts.