Reputation: 128797
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?
Upvotes: 8
Views: 21240
Reputation: 445
I was having the same issue and stumbled across this site: jsbeautifier You might wanna check it out. Worked fine for me ;)
Upvotes: 0
Reputation: 2544
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
in Preferences > General > Keys
.
If no code is selected then Source > Format
seems to always reliably format the entire file. The behaviour of Source > 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 then Source > 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 then source > 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
Upvotes: 4
Reputation: 3838
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'
Upvotes: 11