如何在 Aptana Studio 中自动缩进 JavaScript 代码?
之前我使用 Eclipse 进行 PHP 和 Java 开发,我喜欢使用 Ctrl + i
命令来自动缩进代码。
现在我使用基于Eclipse的Aptana Studio进行JavaScript开发。我想自动缩进我的 JavaScript 代码,但是 Ctrl + i
删除了我的所有代码。 Aptana Studio 中是否有其他命令可以自动缩进 JavaScript 代码?
Previously I used Eclipse for PHP and Java development, and I liked the command Ctrl + i
to automatically indent the code.
Now am I using Aptana Studio that is based on Eclipse, for JavaScript development. I would like to automatically indent my JavaScript code, but Ctrl + i
deletes all my code. Is there any other command that automatically indent JavaScript code in Aptana Studio?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Studio目前还没有这个功能。您可以在此处添加功能请求:https://aptana.lighthouseapp.com/projects /35272-studio/tickets/new
Ctrl+Shift+F 将格式化整个文件,正如蒂姆建议的那样。
您可以通过“窗口 -> ”中的首选项来控制某些格式化程序设置。首选项->阿普塔纳工作室 ->格式化程序'
The Studio does not have this feature yet. You can add a feature request here: https://aptana.lighthouseapp.com/projects/35272-studio/tickets/new
Ctrl+Shift+F will format your entire file, as Tim suggested.
You can control some of the formatter settings through the preferences at 'Window -> Preferences -> Aptana Studio -> Formatter'
也许您指的是格式功能
CTRL+SHIFT+F
?Maybe you mean format feature
CTRL+SHIFT+F
?我刚刚更新到 Aptana Studio 3.0.9,现在它似乎能够在某些情况下格式化特定(选定)的 JavaScript、HTML 和 CSS 行。对我来说,默认的键绑定有些奇怪,所以我在
Preferences > 中将键绑定更改为
。CTRL+I
。一般>键如果没有选择代码,则
Source > Format
似乎总是可靠地格式化整个文件。Source > 的行为选择上的格式
因您正在编辑的代码类型而异:JavaScript
来源>> Format
似乎按您的预期工作:如果您选择几行代码,则Source > Format
将正确缩进选定的代码行。HTML
Source > Format
会做正确的事情。来源> HTML 格式似乎无法预测。
CSS
selector {declaration block; }
),则效果很好(在这种情况下,Aptana 仅格式化该规则)。
块中选择 CSS 的部分,则source > 会被选中。 format
将格式化该除非有人在接下来的几天内指出这篇文章包含致命缺陷,否则我将在 https://jira 上发布功能请求.appcelerator.org 要求跨代码类型的格式化行为保持一致(快速查看现有功能和错误请求表明代码格式化最近受到了相当多的关注)。
更新 19/3/2012 我已在 JIRA 上发布了此错误: https://jira.appcelerator.org/browse/APSTUD-4516
I've just updated to Aptana Studio 3.0.9 and it now seems to be able to format specific (selected) lines of JavaScript, HTML and CSS, in some circumstances. The default key binding for me was something odd so I changed the key binding to
CTRL+I
inPreferences > General > Keys
.If no code is selected then
Source > Format
seems to always reliably format the entire file. The behaviour ofSource > Format
on selections differs depending on the type of code you're editing:JavaScript
Source > Format
appears to work as you'd expect: if you select a few lines of code thenSource > Format
will correctly indent just the selected lines of code.HTML
Source > Format
will do the right thing.Source > Format
seems to act unpredictably with HTML.CSS
selector { declaration block; }
) (in which case Aptana formats just that rule).<style>
block thensource > format
will format all the css within that<style>
block. There seems to be no way to format just a few lines of css within html.Unless anyone points out that this post contains fatal flaws within the next few days, I'll post a feature request at https://jira.appcelerator.org to ask for consistency in formatting behaviour across code types (a quick look at the existing feature and bug requests suggests that code formatting has received a considerable amount of attention recently).
update 19/3/2012 I've posted this bug on the JIRA: https://jira.appcelerator.org/browse/APSTUD-4516
我遇到了同样的问题并偶然发现了这个网站:
jsbeautifier
你可能想检查一下。对我来说效果很好;)
I was having the same issue and stumbled across this site:
jsbeautifier
You might wanna check it out. Worked fine for me ;)