{"id":409,"date":"2010-10-25T14:52:13","date_gmt":"2010-10-25T14:52:13","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2010\/10\/25\/r2010b-comment-wrapping-improvements-continued\/"},"modified":"2010-10-25T14:52:13","modified_gmt":"2010-10-25T14:52:13","slug":"r2010b-comment-wrapping-improvements-continued","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2010\/10\/25\/r2010b-comment-wrapping-improvements-continued\/","title":{"rendered":"R2010b Comment Wrapping Improvements, Continued"},"content":{"rendered":"<p>In our <a href=\"https:\/\/blogs.mathworks.com\/community\/2010\/10\/04\/r2010b-comment-wrapping-improvements\/\">last post<\/a>, we talked about how you no longer have to select anything to tidy up your comments, and about how comment wrapping no longer splits long strings like URLs. In today&#8217;s post we&#8217;ll finish up with a few more improvements. <\/p>\n<p><strong>Wrap where you want<\/strong><\/p>\n<p>If you are <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_prog\/f7-41453.html#f7-38710\">writing MATLAB help<\/a> associated with a class, you may have encountered the following scenario. You want to provide \u201chelp\u201d-style comments for a method, which naturally is indented a bit because of the \u201c<tt>classdef<\/tt>\u201d, \u201c<tt>methods<\/tt>\u201d and \u201c<tt>function<\/tt>\u201d blocks. But comment wrapping occurs at the preferred column (which, for the sake of this example\u2019s screenshots, I have set to 50) without regard for this initial indent:<\/p>\n<p><img src='https:\/\/blogs.mathworks.com\/images\/desktop\/jared_comment_wrapping\/comment-wrapping-short-help.png' alt='comment-wrapping-short-help.png' \/><\/p>\n<p>In other words, instead of a comment block that is 50 characters wide, I only get 50 &#8211; 12 = 38 characters. As a result, when we ask for help on our method, the output is narrower than it would typically be:<\/p>\n<p><img src='https:\/\/blogs.mathworks.com\/images\/desktop\/jared_comment_wrapping\/comment-wrapping-help-output.png' alt='comment-wrapping-help-output.png' \/><\/p>\n<p>In R2010b, we introduced a preference to control this behavior. If you want your comments to have the same character width regardless of the column at which they begin, then choose the \u201ccolumns from start of comment\u201d preference via File > Preferences > Editor\/Debugger > Language:<\/p>\n<p><img src='https:\/\/blogs.mathworks.com\/images\/desktop\/jared_comment_wrapping\/comment-wrapping-preference.png' alt='comment-wrapping-preference.png' \/><\/p>\n<p>Now, your comments will wrap at that many characters from the start of the comment (the \u201c%\u201d character) rather than from the very first column:<\/p>\n<p><img src='https:\/\/blogs.mathworks.com\/images\/desktop\/jared_comment_wrapping\/comment-wrapping-long-help.png' alt='comment-wrapping-long-help.png' \/><\/p>\n<p>And the \u201dhelp\u201d output will always be a consistent width:<\/p>\n<p><img src='https:\/\/blogs.mathworks.com\/images\/desktop\/jared_comment_wrapping\/comment-wrapping-long-help2.png' alt='comment-wrapping-long-help2.png' \/><\/p>\n<p>Since most people want their code to wrap at a fixed location, this preference is set to &#8220;columns from start of line&#8221; by default.<\/p>\n<p><strong>Wrap block comments<\/strong><\/p>\n<p>Do you use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_env\/brqxeeu-23.html#brqxeeu-34\">block comments<\/a>? Many users had wondered why they didn\u2019t have the same wrapping capabilities as regular line comments. Now they do:<\/p>\n<p><img src='https:\/\/blogs.mathworks.com\/images\/desktop\/jared_comment_wrapping\/comment-wrapping-block-comments.png' alt='comment-wrapping-block-comments.png' \/><\/p>\n<p>If you copy and paste large bodies of text into block comments, or simply write the occasional novella within your MATLAB code, you can now make them nice and neat with a keystroke. <\/p>\n<p><strong>That&#8217;s a wrap<\/strong><\/p>\n<p>That&#8217;s it for our deep dive into this feature. Thanks for reading, and let me know if you get a chance to try out these improvements, and what else you&#8217;d like to see!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last post, we talked about how you no longer have to select anything to tidy up your comments, and about how comment wrapping no longer splits long strings like URLs. In today&#8217;s post&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2010\/10\/25\/r2010b-comment-wrapping-improvements-continued\/\">read more >><\/a><\/p>\n","protected":false},"author":51,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,9],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/409"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/51"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=409"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/409\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}