是否存在允许您以不同缩进样式查看源代码的编辑器?

发布于 2024-08-18 22:42:07 字数 502 浏览 4 评论 0原文

这不是一个主观问题,也不是一个争论性问题,而是一个需要是/否答案的问题,如果答案是肯定的,还需要所述编辑的姓名。

想象一下,公司指南要求提交的代码使用 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 技术交流群。

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

发布评论

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

评论(3

临走之时 2024-08-25 22:42:07

Vim 允许您准确指定缩进的工作方式。检查一下:

http://vimdoc.sourceforge.net/htmldoc/indent.html#cinoptions-values

一旦指定,请使用以下命令重新缩进整个文档:

1G=G

然后您所需要做的就是编写一个宏来设置缩进样式,重新缩进并保存,以及另一个在打开文件时自动加载正确的缩进样式的宏。

Vim allows you to specify exactly how you want it's indenting to work. Check out:

http://vimdoc.sourceforge.net/htmldoc/indent.html#cinoptions-values

Once it is specified, re-indent the whole document with:

1G=G

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.

云胡 2024-08-25 22:42:07

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.

轻拂→两袖风尘 2024-08-25 22:42:07

没有。  

No.    

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