Comments In SharePoint Designer

Comments in SharePoint designer

In this article, I will show How to 

Add comments on a highlighted code in SharePoint Designer.

Comments in SharePoint designer

If you are working with SharePoint designer to edit master pages, Page layout, JS and CSS files, you will not that there is no comment and uncomment button like Visual Studio!

Check also SharePoint designer 2016 and InfoPath 2016 in sharepoint server 2016, what’re the alternatives?

Actually, the SharePoint Designer is not considered a smart dedicated code editor, however, you can insert a comment through the following:

Insert a comment in SharePoint Designer.

  1. Go to Edit tab > Insert Tag > Insert Comment tag.
  2. You can easily use CRTL + / to insert  a new comment tag.

Insert Comment in SharePoint Designer

Unfortunately, the comment tag is only working for HTML tags, not working with JS, CSS code.

Comment CSS Code in SharePoint Designer

Additionally, if you have tried to highlight your code then inserted a comment tag you will note that the highlighted code replaced with the comment tag as shown below:

Comment highlighted code in SharePoint Designer


Comment a highlighted code in SharePoint Designer.

As I mentioned above, the insert comment tag is useless because it does not comment on the highlighted code.

By dint of the Code Snippet, you can easily apply a comment on the highlighted code.

Code Snippet in SharePoint Designer

Comment HTML highlighted code in SharePoint Designer.

  1. In Edit Tab > Code Snippet category.
  2. Click on Create button to create a new code snippet.
  3. Provide the snippet name and the description as you prefer.
  4. add a single pipe | surrounded with the comment tag to preserve the highlighted code.

Comment highlighted HTML code in SharePoint Designer

The final snippet should look like

[code language="HTML"]
<!-- | -->
[/code]

Comment JS/CSS code in SharePoint Designer

  1. In Edit Tab > Code Snippet category.
  2. Click on Create button to create a new code snippet.
  3. Provide the snippet name and the description as you prefer.
  4. add a single pipe | surrounded with the comment tag /* */ to preserve the highlighted code.
[code language="HTML"]
/* | */
[/code]

Apply comment code snippet

  1. Highlights the code that you want to comment on it.
  2. Click on Ctrl + Enter to show the code snippet list.
  3. Select your comment snippet.

Comment highlighted CSS code in SharePoint Designer


Uncomment button in SharePoint Designer 

Unfortunately, you will need to remove the comments tag manually to uncomment your code!


Applies To

  • SharePoint Designer.
  • SharePoint Online.
  • SharePoint Server.

Conclusion

In this article, I have explained How to comment the highlighted HTML/JS/CSS code in SharePoint Designer using Code Snippet.

See Also

 

3 thoughts on “Comments In SharePoint Designer”

  1. Pingback: The Workflow contains errors, but they are not visible in the current view

  2. It’s an remarkable poxt designed for all the
    online users; they will get benefit from it I
    am sure.

  3. Pingback: Create Custom Page Layout using SharePoint Designer | SPGeeks

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top