Dreamweaver 扩展美化 PHP/JavaScript/jQuery 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2040500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dreamweaver extension to beautify PHP/JavaScript/jQuery code
提问by Adnan
I'm looking so long for a Dreamweaver extension to auto beautify PHP / JavaScript / jQuery code. Currently Dreamweaver can beautify only HTML and CSS (Apply Source Formatting).
我一直在寻找 Dreamweaver 扩展来自动美化 PHP / JavaScript / jQuery 代码。目前 Dreamweaver 只能美化 HTML 和 CSS(应用源格式)。
Any kind of help will be much appreciated.
任何形式的帮助将不胜感激。
采纳答案by user3448798
Online solutions for validation and formatting JavaScript:
用于验证和格式化 JavaScript 的在线解决方案:
Validate JavaScript code:
http://www.javascriptlint.com/
Format JavaScript code:
http://jsbeautifier.org/
回答by samia
You can use PhpEdit, it's an extra debugger!
DW doesn't do debug, you find the error if and only if you run your code.
您可以使用 PhpEdit,它是一个额外的调试器!
DW 不进行调试,当且仅当您运行代码时才会发现错误。
With PhpEdit, it is onTime.
使用 PhpEdit,它是准时的。
回答by antony
For the PHP side of things use https://github.com/fabpot/PHP-CS-Fixer
对于 PHP 方面,请使用https://github.com/fabpot/PHP-CS-Fixer
This short excerpt and more information is taken from the README.
这段简短的摘录和更多信息来自自述文件。
Installation:
Download the
php-cs-fixer.pharfile and store it somewhere on your computer.Usage:
The fix command tries to fix as much coding standards problems as possible on a given file or directory:
php php-cs-fixer.phar fix /path/to/dir php php-cs-fixer.phar fix /path/to/file
安装:
下载
php-cs-fixer.phar文件并将其存储在计算机上的某个位置。用法:
fix 命令试图在给定的文件或目录上修复尽可能多的编码标准问题:
php php-cs-fixer.phar fix /path/to/dir php php-cs-fixer.phar fix /path/to/file
回答by Shady Nawara
I have found this great dreamweaver extenstion, just give it a try
我找到了这个很棒的 Dreamweaver 扩展,试试看
Their Homepage: http://www.decodize.com/projects/
他们的主页:http: //www.decodize.com/projects/
extension download page: http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=2107536
扩展下载页面:http: //www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us& extid=2107536
回答by Jake N
Maybe try http://www.javascriptlint.com/says it works on some IDEs, maybe DW is one of them.
也许尝试http://www.javascriptlint.com/说它适用于某些 IDE,也许 DW 是其中之一。
Try googling, but use 'code format' not 'beautify'
尝试谷歌搜索,但使用“代码格式”而不是“美化”
回答by user3089840
I was wondering if you could elaborate on how to set this up. I see the CSS and Tag Libraries options under "Advanced Formatting", but I am stuck at that point as to how to get my PHP to start auto-indenting.
我想知道您是否可以详细说明如何设置。我在“高级格式”下看到了 CSS 和标签库选项,但我在这一点上遇到了如何让我的 PHP 开始自动缩进的问题。
Or, if Dreamweaver has somehow fixed this problem, let me know! It seems like every other IDE has an auto-indent feature! Thanks :)
或者,如果 Dreamweaver 以某种方式解决了这个问题,请告诉我!似乎所有其他 IDE 都有自动缩进功能!谢谢 :)
回答by Phill Pafford
It's been a while since I have used DW, I use Aptana now and there is an option to format the code from one of the drop down menus. Just use something like "control a" (To select all your code), "control f" (To format your code). There might be another key combination but I think this will work if memory serves.
自从我使用 DW 已经有一段时间了,我现在使用 Aptana,并且有一个选项可以从一个下拉菜单中格式化代码。只需使用诸如“control a”(选择所有代码)、“control f”(格式化代码)之类的东西。可能还有另一个组合键,但我认为如果没有记错的话这会起作用。
Maybe "esc control f"
也许“esc control f”
回答by Danilo Celic
I've not seen anything for Dreamweaver, but if you can copy ans paste the code, http://jsbeautifier.org/can help you with making code look a good bit better. I've just tried it on some packed JavaScript and it worked out very well. You can also download the application and run it locally (it's only HTML and JavaScript), so you won't need an internet connection to get your code prettier.
我没有看到有关 Dreamweaver 的任何内容,但是如果您可以复制和粘贴代码,http://jsbeautifier.org/可以帮助您使代码看起来更好一些。我刚刚在一些打包的 JavaScript 上尝试过它,效果很好。您还可以下载该应用程序并在本地运行它(它只是 HTML 和 JavaScript),因此您不需要 Internet 连接来使代码更漂亮。
回答by Drmzindec
Best way i found is to set the way Dreamweaver displays code yourself. Sure it takes some time to do but its worth it.
我发现最好的方法是自己设置 Dreamweaver 显示代码的方式。当然这需要一些时间来完成,但它是值得的。
Here is how:
方法如下:
Dreamweaver: Edit > Preferences > Code Format
Dreamweaver:编辑 > 首选项 > 代码格式
Then under Advanced Formatting you can pick CSS... or Tag Libraries...
然后在 Advanced Formatting 下,您可以选择 CSS... 或 Tag Libraries...
You can make any of your code look as it should this way.
您可以通过这种方式使您的任何代码看起来都应该如此。
Like i said, will take some time but do it once and you can keep using it with all your future Dreamweaver versions.
就像我说的,这需要一些时间,但只做一次,您就可以继续在所有未来的 Dreamweaver 版本中使用它。
回答by MiPhyo
In Dreamweaver CS6 no need any other extension or tools. Just select your code and then Go to 'Commands' > 'Apply Source Formatting' or 'Apply Source Formatting to Selection'
在 Dreamweaver CS6 中不需要任何其他扩展或工具。只需选择您的代码,然后转到“命令”>“应用源格式”或“将源格式应用于选择”
Done. :)
完毕。:)

