locked
Code Formatting in SharePoint Designer RRS feed

  • Question

  • I've noticed that SharePoint Designer 2010 seems to see fit to rework my nicely-formatted code into ... something that doesn't look so nice.  I found that on a page layout I was working on -- if I included an ASPX comment, i.e.  <%-- comment here --%>, SharePoint designer in it's infinite wisdom would place this, as well as every subsequent element until </asp:content> on a single line.  It seems to recognize spaces between elements, i.e. if I have a <p>Test</p> tag directly after the comment, I can put line breaks anywhere within the inner text node, and it will keep them -- but when I try and add a few lines between this and a sibling element, a save would bump both siblings onto a single line. 

    It's not a huge deal -- for the most part it just hampers my productivity -- but there are very few cases [rare, though they do exist] where the presence or lack of presence of a space in HTML can mess up the output....  I haven't hit one yet, but when I do I know I'll be cursing this program. 

    For the most part, it's mostly frustrating because the "helpful" nature of the program completely breaks the ability to simply read and edit the code -- it updates it on save, and must be parsed to different lines every time the file is edited.  I've noticed there is an option page for "Code Formatting" but this seems to only cover CSS and a subset of HTML ... none of the more fancy pieces that can appear within an ASPX page such as <asp:content/> pieces and comments are covered.... also there is a glaring lack of an option "Turn off code formatting".

    Is there a way to turn off any and all attempts by SPD to format code?

    Thanks.

    Wednesday, November 30, 2011 3:43 AM

Answers

  • Hi,

    The Code View Tools tab you have already found, and that is the only way to influence to display of code in SharePoint Designer.


    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    • Proposed as answer by Eric Skaggs Wednesday, November 30, 2011 12:00 PM
    • Marked as answer by tswaters Thursday, December 8, 2011 9:09 PM
    Wednesday, November 30, 2011 7:06 AM
  • Hi ,

     

    You can disable the close Tag function by changing the Page Editor Options .

    1.       Open SPD and choose File>Options>Page Editor Options>Intellisense .

    2.       Uncheck ‘Close Tag’ under Auto Insert .

    3.       Save the changes .

     

    Thanks,

    Entan Ming

    • Marked as answer by Entan Ming Wednesday, December 7, 2011 2:10 AM
    Thursday, December 1, 2011 7:57 AM

All replies

  • Hi,

    The Code View Tools tab you have already found, and that is the only way to influence to display of code in SharePoint Designer.


    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    • Proposed as answer by Eric Skaggs Wednesday, November 30, 2011 12:00 PM
    • Marked as answer by tswaters Thursday, December 8, 2011 9:09 PM
    Wednesday, November 30, 2011 7:06 AM
  • Thanks for the confirmation.  

    I realize this is a free program -- so expectations are low.... But it would be nice if there was an option to turn all this stuff off.

    In addition to 'code formatting' issues, a lot of the autotext stuff is rather annoying to me.  I write my CSS/HTML rather quickly and find I need to remove closing elements that SPD adds for me... i.e. I'll type my css selector then a quick "{}" only to find "{}}" on the screen with a line break, same idea with html -- I'll  type something like <b></b> only to find <b></b></b>...  Very annoying.

    Wednesday, November 30, 2011 9:02 PM
  • Hi ,

     

    You can disable the close Tag function by changing the Page Editor Options .

    1.       Open SPD and choose File>Options>Page Editor Options>Intellisense .

    2.       Uncheck ‘Close Tag’ under Auto Insert .

    3.       Save the changes .

     

    Thanks,

    Entan Ming

    • Marked as answer by Entan Ming Wednesday, December 7, 2011 2:10 AM
    Thursday, December 1, 2011 7:57 AM