一台漂亮的打印机“统治一切”
我正在寻找一种可以以尽可能多的语言漂亮打印(又名整洁或美化)源代码的工具。 我特别感兴趣的包括:
- Java
- JSP
- HTML
- JavaScript
- SQL
- JSON
- XML
理想情况下,该工具应该能够就地更新源文件,并且能够一次格式化多个文件。 如果它能够格式化包含多种语言的文件(例如包含 HTML、Java 和 JavaScript 源代码的 JSP),那就太好了,但这可能要求有点高。
我已经找到了一个商业工具,它似乎涵盖了很多语言,但免费的甚至是更好:)
顺便说一句,我知道有一个漂亮的打印机可用于大多数语言,但我正在寻找的是“一站式商店”。
干杯, 大学教师
I'm looking for a tool that can pretty-print (AKA tidy or beautify) source code in as many languages as possible. Those I'm particularly keen on include:
- Java
- JSP
- HTML
- JavaScript
- SQL
- JSON
- XML
Ideally, the tool should be able to update source files in-place and be able to format more than a single file at-a-time. It would be great if it could format files containing multiple languages (e.g. a JSP containing HTML, Java, and JavaScript source code), but that's probably asking for a bit much.
I've already found a commercial tool that seems to cover a lot of languages, but a free one would be even better :)
BTW, I know there is a pretty printer available for most languages, but what I'm looking for is a "one-stop shop".
Cheers,
Don
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我一直使用 Vim 来做这件事。 它不能很好地处理 HTML,但可以处理其他内容。 使用 Vim 命令可以轻松地在多个文件上自动运行它。
I use Vim to do this all the time. It doesn't handle HTML very well, but it does the others. It's easy to use the Vim commands to automate running it on a number of files.
维基百科有一个很大的列表。 不过,我很想知道这里可能会出现什么共识。
多个处理多种语言; 例如
PrettyPrinter,(适用于每种编程语言的开源美化器)
UniversalIndentGUI(适用于任何漂亮打印机的图形用户界面,可实时预览格式设置)
Prettyprinter.de,(适用于 PHP、Java、C++、C、Perl、 JavaScript、CSS)
Wikipedia has a good-sized list. I'm interested to see what consensus might emerge here, though.
Several handle multiple languages; e.g.
PrettyPrinter, (an Open Source beautifier for every programming language)
UniversalIndentGUI (A graphical user interface for any pretty printer with live preview for the formatting settings)
prettyprinter.de, (an online beautifier for PHP, Java, C++, C, Perl, JavaScript, CSS)
对于 Haskell,我在
~/bin/pp.hs
中有这个:在 Vim 中,
:set equalprg=~/bin/pp.hs
,选择一个区域,点击 < code>=,然后,它就被美化了。好吧,这不是很一般。 但我认为如果我将其添加到此处,它对某人有帮助的机会很小。
For Haskell, I have this in
~/bin/pp.hs
:In Vim,
:set equalprg=~/bin/pp.hs
, select a region, hit=
, and boom, it gets prettified.Okay, it's not very general. But I figure it has a small chance of helping somebody if I add it here.
Emacs 是我个人最喜欢的。 有些附加组件几乎支持您能使用的所有语言。
Emacs is a personal favorite of mine. There are add-ons that allow for almost every language you can thing of.
我使用 UltraEdit 并发现它总体上相当不错。 它不是免费的,但也不是那么贵。
I use UltraEdit and find it's generally pretty good. It's not free, but it's also not that expensive.