[Flex] Source code formatting Follow
Hi,
I come from Flex Builder and have been used to this lovely little utility: http://sourceforge.net/projects/flexformatter/files/ for formatting MXML and AS code.
I can see there's a Code > Reformat Code... option ( CTRL+ALT+L ) in IDEA but is there a way I can customise the formatting settings and perhaps force the reformating on save or check in?
Thanks,
Nick
Please sign in to leave a comment.
File | Settings | Code Style to customize.
'Reformat code' check box at Commit dialog.
There's no option to reformat on save, because IDEA user never need to press 'Save' button. Highlighting is always in sync with what you see in editor, so you absolutely do not care at which moment content is dumped to HDD. If you got used to press Ctrl+S each second, you can map 'Reformat code' to this shortcut :)
Alex, thanks for the reply... I'l have a tinker with the setting but do you know which to use for .as or .mxml files. In some of the settings, there are references to Java, XML, Yamp, Javascript, etc...
Cheers,
Nick
p.s. I don't think I can make FOTB.
Hi,
Is there a way I can control which attributes are grouped together and which order they appear?
e.g... I always want my ID attribute at the top followed by width and height on the same line, followed by x, y, top, left, right, bottom
<mx:Vbox id="myVBox"
width="200" height="300"
x="10", y="50" />
Also, I'd like to keep my braces {} inline with each other but I can't see to find that as an option.
Thank for your help,
Nick
MXML files have XML format, so settings are under Code Style | General | XML and Code Style | XML. AS files and ActionScript parts of MXML (like content of Script tag) are formatted according to ActionScript rules which are at Code Style | Wrapping and Braces | ActionScript, Code Style | Blank Lines | ActionScript, Code Style | Spaces | ActionScript and Code Style | JavaScript/ECMAScript/ActionScript.
Settings look a bit messed up in IDEA 10.5 and will be redesigned for IDEA 11.
I'm afraid there are no options to rearrange attribute order and grouping on lines.
Hi Alex,
I'm just getting round to trying this but I can't find this option... 'Reformat code' check box at Commit dialog.
I'm using IDEA 9.0.3 - Was it introduced after this?
Nick
Hi Nick,
yep, I believe this is introduced in v10.
Hi() : void
{
I'm not sure if this doesn't exist or I just can't see it, but is there a code formatting option so the code block braces {} are in alignment with each other, e.g.
private function onExport() : void
{
}
as opposed to this...
private function onExport() : void {
}
The same goes for decision and looping statements
{
}
}
Thanks :-}
Settings | Code Style | Wrapping and Braces, then select ActionScript tab, then look at 'Braces placement' node in the tree.
Ah Thanks... 9.0.3 must be different, I got it after a prefs search though.
Alex,
When you say IDEA users don't need to press Save, I'm assuming that applies to 9.0.3 users as well?
Is there a way of disabling this feature? I prefer having a confirmation dialog when closing an edited file, that I haven't explicitedly saved myself...
Cheers,
Nick
Oh, no. IDEA never had and will never have file save confirmation dialog. There's 'Local History' feature to rollback to any previously saved state even if you don't use VCS. Believe me, you'll miss this feature in other tools after working with IDEA for a while. You need to revert content 100 times less frequently than to save file. Extra dialogs waste user experience.
Hi, I understand and agree about the dialog box UI interference and I try to avoid them myself but it does have it's place.
Old habits die hard and every other editor I've used doesn't work like this... Source code is pretty special stuff and if edited and saved accidently, I can introduce bugs and debugging/ fixing time. I'd rather opt for a Save Me dialog :-)
Here's my Use Cases:
* I will often open up a Class and declare another Class variable so I can get the full import statement from the top.
* I edit code with spaces , CRs and // comments whilst reading it, a bit like marking up with a pencil when reading a book...
* I reformat the Class with my custom code format settings when reading it.
* I accidently hit CTRL + D or worse still CTRL + Y when saving or trying to redo typing... :)
Apologies for comparing IDEA to Eclipse but I guess feedback is a positive thing... So is it possible to do one of these:
1). Have an option to disable auto-saving.
2a). Make it obvious that a file has changed (Eclipse puts a * in the tab filename) - The red tab squiggle is good for typos but the blue from black font colour isn't too clear. Maybe invert the actual tab colours. Black tab with white filename.
2b). Then... Provide a Quick way to perform a Local History Rollback to the point it was opened.
I am getting more used to IDEA and it is pretty cool but I guess everyone will have quirks about something :)
Thanks for listening...
Nick
I'm not going to argue now, there are megabytes of similar discussions stored over internet for 10 years. And IDEA's approach wins.
The answers are following:
1. No
2a. If you use any VCS then File name color shows modification status. Also 'Changes' tool window provides full information in convenient way.
2b. I believe it's easy enough, isn't it?
As for habbits - when going to temporarily modify files you can switch to separate Changelist and then revert it fully in one click (assume you use any VCS and files are not locally modified before start)
Alex,
It's not an argument, it's feedback about how a user writes code and uses IDE's.
Perhaps in your opinion it does win, but not in mine (yet, perhaps) and perhaps many others still disagree who have commented in those megabytes of similar discussions... Otherwise every other IDE and text editing application would work in the same way as IDEA.
Easy to me = Minimal keystrokes. e.g. ESCAPE, TAB, SPACE in all IDE's that I'm aware of and in all applications I use (including Notepad, MS Word, DreamWeaver, Excel, Eclipse, MS Outlook, Photoshop, Gimp, OpenOffice) will close the current document and not save changes. Now that consistancy is pretty awesome isn't it, it's a world wide accepted UI behaviour used across many software vendors.
I am in the dark with the 'seperate Changelist' mode so I'll hunt the docs for that, thanks for the tip.
... And to be honest I have only been using IDEA for 5 weeks so I am still new to it so perhaps there are a few keyboard strokes I can do to an edited file to achieve the same thing that ESCAPE, TAB, SPACE does. Are you aware of them?
Cheers,
Nick
As soon as you configure any VCS (File | Settings | VCS) you'll see convenient changes highlighting and Changelists. I don't think you need to go through docs first, all concepts are easy to understand and use.
Minimum keystrokes is our first priority driver. I suggest you to print Help | Default Keymap Reference. Also you'll find useful 'Find Action' action (Ctrl + Shift + A)
Hi,
We are using SVN if that's what you mean?
And I can see blue files in the 1:Project window. and can right click the line numbers and select Annotate.
I've got the Default keyboard map stuck next to my monitor and I know that CTRL+F4 closes the active document.
Is there a shortcut to revert any changes to when ithe document was 'opened', not last updated from SVN? I don't want to perform an SVN Revert.
Cheers Alex,
Nick
Yes, SVN is a VCS :). So, Changelists are in Changes tool window. No, there's no action to revert to the state when you first opened file in the editor, so the only way is Local History. May be you'll find Local History Labels useful.
Alex, cheers for your help...
I've used Local History previously, in fact it's a god send.
Going back to my original issue though of wanting to Close without saving changes, it appears it can't be done using quick successive keystrokes.
I need to:
open
set a "file opened" History Label
edit file
Right Click, select Local History
Right Click "file opened" Label and select Revert.
Not exactly speedy so I'd opt for ESC, TAB, SPACE any day :-)
Although, I think the closest thing I can get to what I want is by assigning a Keystroke to the SVN Rollback option such as CRTL+Alt+Shift+Z, then hitting ENTER (to the confirm dialog), then hitting CTRL+F4 (to close).
I'm using IDEA 9.0.3 and the Macro feature isn't powerfull enough, do you know if later versions of IDEA allow for more powerfull macros/ scripting?
Perhaps if IDEA included "File opening" in "Setting > IDE > Local History > Automatic Labelling" I could then create a Macro/ Script & Keystroke to revert back to the last "File Opening", then hit CTRL+F4.
Should I put this suggestion in a special feedback forum?
Thanks,
Nick
Also just holding Ctrl+Z for some time can help in most cases.
I tried that, and it actually goes past the point of File Open edits... It will keep undoing until the SVN Revert point in time.
sory about the intrusion but how come theres no more (Flex tutorial in the Intellij wikki page) the link is blank and where can I find a flex tutorial for intellij 11 ultimate
The auto-save, or more like it transparent save is an amazing feature! It's hard in the beggining but now I don't see myself without it.