是否存在允许您以不同缩进样式查看源代码的编辑器?
这不是一个主观问题,也不是一个争论性问题,而是一个需要是/否答案的问题,如果答案是肯定的,还需要所述编辑的姓名。
想象一下,公司指南要求提交的代码使用 K&R 风格,并且我更喜欢 Allman(例如)。是否有编辑器(独立的或 IDE 的一部分)允许您始终使用 Allman 风格“查看”源代码,但始终使用 K&R 风格保存文件?
这似乎并不那么牵强,也不是那么复杂:源代码/文本文件将始终使用“官方”样式保存,但是编辑器在屏幕上显示的内容并不完全是您的文本文件,而是一个使用您选择的缩进样式“查看”文本文件。因此,每个开发人员都可以自由选择他/她喜欢的缩进样式。
是否存在这样的编辑器(独立的或与 IDE 集成的)?
请注意,我实际上是在问是否存在可以执行此操作的编辑器,而不是是否存在允许执行类似操作的工作流程(例如建议我使用 GNU indent< /em> 在执行我的 Mercurial hg commit 之前,没有接近问题的答案)。
This is not a subjective nor an argumentative question but a question that needs a yes/no answer and, if the answer is positive, the name(s) of said editor(s).
Imagine the company guideline mandates committed code to use the K&R style and that I prefer Allman (for example). Are there editors (either standalone or part of an IDE) that allow you to always "view" your source code using the Allman style, yet always save the file using the K&R style?
It doesn't seem that far-fetched nor that complicated: the source code/text file would always be saved using the "official" style, but what the editor would show you on-screen wouldn't be exactly your text file but a "view" of your text file using the indent style of your choice. And hence every developer would be free to choose the indent style he/she preferred.
Does an editor (either standalone or integrated with an IDE) that does this exist?
Note that I'm really asking if there exist editor(s) that do this, not if there are workflows allowing one to do something similar (for example suggesting to me to use GNU indent before doing my Mercurial hg commit is not anywhere near an answer to the question).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Vim 允许您准确指定缩进的工作方式。检查一下:
一旦指定,请使用以下命令重新缩进整个文档:
然后您所需要做的就是编写一个宏来设置缩进样式,重新缩进并保存,以及另一个在打开文件时自动加载正确的缩进样式的宏。
Vim allows you to specify exactly how you want it's indenting to work. Check out:
Once it is specified, re-indent the whole document with:
Then all you need is to write a macro to set indent style, re-indent and save and another one that autoloads the correct indent style when opening a file.
Visual Age for Java 具有类似的功能:其内部 SCM 以非文本格式存储 Java 源代码的内容,保留对编译器重要的所有信息。每个开发人员都可以决定他想要如何查看 Java 源代码。
这包括在没有周围类的情况下查看方法/字段,以及使用您想要的任何代码布局(包括自定义代码布局)的能力。
此页面说明如何编写自定义格式化程序。不幸的是,我找不到此功能的任何实际截图。
Visual Age for Java had a similar feature: Its internal SCM stored the content of your Java sources in a non-text format that kept all the information that's important for the compiler. Each developer could decide how exactly he'd like to view the Java sources.
This included viewing methods/fields without the surrounding class and also the ability to use any code layout you'd like (including custom ones).
This page explains how to write a custom formatter. Unfortunately I couldn't find any screenshots of this feature in action.
没有。
No.