4 Replies Latest reply on Nov 7, 2008 6:42 AM by Mitek17

    any way to format code in Flex Builder?

    deuce4
      This is driving me crazy, coming from a Visual Studio background. I like to program fast and furious, and when I am done all the tabs and indentation in my code is whacky. Is there any way to "organize" and format the code automatically in FLEX?

      By format I just mean to reset all the tabs in a consistent manner based on the curly braces, etc.

      Thanks for any hints.
        • 1. Re: any way to format code in Flex Builder?
          Mitek17 Level 1
          I have the same problem, code formatting is not the best thing in Flex. I am using AnyEdit plugin ( http://andrei.gmxhome.de/anyedit/) which substitutes for me all tabs to spaces.

          Still there is some weird behaviour of Flex for Mac (I LOVE MAC!!!!) it inserts a tab and 1 more extra space or just 5 spaces, so when you convert all tabs to spaces, there will be misalignment for code edited on Mac (I LOVE IT!!!).

          Another strange thing is in MXML files: when you hit Enter after the <Mx:Source> block it places cursor in one position, but if Flex adds import automatically it places it with different alignment.

          I don't consider this to be a big problem, just an inconvenience, but unfortunately these tiny inconveniences are the things that constitute our lives.

          Cheers,
          Dmitri.


          • 2. Re: any way to format code in Flex Builder?
            Jed Schneider Level 1
            RE Dimitri, For OS X,
            You dont need a plugin to remove tabs, just select in your Flex Builder/Eclipse preferences to use spaces instead of tabs. On the Mac, I choose to use Text Expander, a separate program that watches for keystrokes to auto-insert text. I disable the code completion (like matching curly braces) and "create snippets from selection" (install text expander and you'll figure it out). That creates all the indentation and formatting automatically. The only downside is that i have separate key combinations for different editors. So, in Flex Builder "*comment" will add a multiline actionscript comment and ",comment" will add an mxml comment, but in Coda it is "**comment" and ",,comment". The other great hotkey in Flex Builder is control-space, which brings up the code completion list, that way you don't end up with tons of double spaces between properties in an xhtml tag.
            • 3. Re: any way to format code in Flex Builder?
              Level 7

              "Jed Schneider" <webforumsuser@macromedia.com> wrote in message
              news:gf1fm0$8n4$1@forums.macromedia.com...
              > RE Dimitri, For OS X,
              > You dont need a plugin to remove tabs, just select in your Flex
              > Builder/Eclipse preferences to use spaces instead of tabs. On the Mac, I
              > choose
              > to use Text Expander, a separate program that watches for keystrokes to
              > auto-insert text. I disable the code completion (like matching curly
              > braces)
              > and "create snippets from selection" (install text expander and you'll
              > figure
              > it out). That creates all the indentation and formatting automatically.
              > The
              > only downside is that i have separate key combinations for different
              > editors.
              > So, in Flex Builder "*comment" will add a multiline actionscript comment
              > and
              > ",comment" will add an mxml comment, but in Coda it is "**comment" and
              > ",,comment". The other great hotkey in Flex Builder is control-space,
              > which
              > brings up the code completion list, that way you don't end up with tons of
              > double spaces between properties in an xhtml tag.

              My favorite shortcuts are Ctrl-D to delete the entire current line and
              Ctrl-Alt-UpArrow or Ctrl-Alt-DownArrow, to copy the entire selection up one
              line or down one line.


              • 4. Re: any way to format code in Flex Builder?
                Mitek17 Level 1
                quote:

                Originally posted by: Jed Schneider
                You dont need a plugin to remove tabs, just select in your Flex Builder/Eclipse preferences to use spaces instead of tabs. tag.


                Hi Jed,

                I use AnyEdit for 2 reasons: a) it changes tabs to spaces in the whole file upon save, when Flex standard way is to substitute tabs while you type them - it won't work on Copy-n-Paste or on the old/imported/whatever files
                b) AnyEdit changes empty lines with spaces with CR/LF, it makes diff more cleaner.


                Thanks for the advice re TextExpander for Mac - I'll have a look.

                Cheers,
                Dmitri.