是否允许您以不同的缩进样式查看源代码?

Syn*_*r0r 10 language-agnostic version-control 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).

sle*_*man 1

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

http://vimdoc.sourceforge.net/htmldoc/indent.html#cinoptions-values
Run Code Online (Sandbox Code Playgroud)

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

1G=G
Run Code Online (Sandbox Code Playgroud)

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