6 Replies Latest reply: Jun 22, 2013 7:57 AM by jyeager11 RSS

    About Dreamweaver's "Apply Source Formatting"

    jyeager11 Community Member

      Hi,

       

      Currently, the "Apply Source Formatting" command does a decent, but not good enough job of aligning things in my code.

       

      For instance, elements in the <head> aren't offset in any way. They're all left-justified, instead of being idented by two spaces like they should. Same with certain other tags.

       

      In a perfectly-structured world, everything between an opening tag and a closing tag would be offset by two spaces, whether it's the <head></head> tags, the <body></body> tags, the <div></div> tags, etc.

       

      Is there any way for me to force this? A "hardcore formatting" mode I may be unaware of?

       

      If not, does anyone here use any 3rd party software to format and order their code properly? Perhaps even something that lets us customize what tags we want the thing to ignore, like <b></b>.

       

      Thanks!

        • 1. Re: About Dreamweaver's "Apply Source Formatting"
          Jon Fritz II CommunityMVP

          Yes, you can adjust the formatting of every tag individually by going to Preferences > Code Format > Advanced Formatting: Tag Libraries

          • 2. Re: About Dreamweaver's "Apply Source Formatting"
            mhollis55 CommunityMVP

            I routinely go back and forth between Dreamweaver and BBEdit. I often use BBEdit's "entab" function to help with source formatting but in the <head> region there is never any indentation.

             

            And there are reasons for that. Elements in the <head> region ought not need source formatting, with the exception of JavaScript you write in there. And that JavaScript is always (both in BBEdit and in Dreamweaver's code view) indented properly.

             

            Of course, you can manually insert tabs for yourself.

            • 3. Re: About Dreamweaver's "Apply Source Formatting"
              jyeager11 Community Member

              mhollis55 wrote:

               

              And there are reasons for that. Elements in the <head> region ought not need source formatting, with the exception of JavaScript you write in there. And that JavaScript is always (both in BBEdit and in Dreamweaver's code view) indented properly.

               

              Of course, you can manually insert tabs for yourself.

               

              I've been doing that (inserting spaces - not tabs - manually) and I'm tired of doing it. Hence the question.

               

              And I'm not sure why you WOULDN'T want the contents of your <head> and <body> to be idented. There's no downside and it makes spotting the end of the head / beginning of the body much easier without having to use search/replace.

              • 4. Re: About Dreamweaver's "Apply Source Formatting"
                jyeager11 Community Member

                Awesome. Can you tell me if there's a way to restore defaults? I'm not seeing one, and I should probably know if one exists before I go playing in there a little too recklessly.

                • 5. Re: About Dreamweaver's "Apply Source Formatting"
                  Jon Fritz II CommunityMVP

                  I don't think there is one, unfortunately.

                   

                  In DWCS4 you can make a copy of the TagLibraries folder (or individual tag sets within the TagLibraries folder) at...

                   

                  Program Files(x86) > Adobe > Adobe DW CS4 > configuration > TagLibraries

                   

                  Then revert to the old copy if you botch something too far to fix it from within DW.

                  • 6. Re: About Dreamweaver's "Apply Source Formatting"
                    jyeager11 Community Member

                    Having now played around with it, I've noticed bugs with the custom tag formatting.

                     

                    For instance, if I select "Before, Inside, After" and "Formatted and Indented" for ther <style> pr <script> tags, the closing tag is never indented with the rest. And the first line of the contents, either.

                     

                    The first opening tag will be indented depending on where in the code it's located. The conents will *sometimes* be indented (the first line is often not, and it's not even aligned with the open tag -- it's completely left justified) and then the other lines inside the open/close tags are perfect indented until the closing tag, which never is. So more often than not, the code looks like :

                     


                    <div id="medrect">

                    <div class="inner">

                    <script type="text/javascript">

                    adSetType('F');htmlAdWH('93310585','RR','RR');adSetType('');

                    </script>


                    </div>

                    </div>

                     

                    I don't know if that worked, since spaces and indentation is hard to reproduce on an HTML page.

                     

                    EDIT: Wow, that did not work out as intended. Since I can't do multiple spaces here, I won't even try to illustrate what I mean.. but suffice it to say there is a lot of manual fixing-up that comes after an Apply Formatting, even if they let us determine tag behavior during code formats... because the feature is faulty.