{"id":370,"date":"2010-03-22T15:21:14","date_gmt":"2010-03-22T15:21:14","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2010\/03\/22\/tab-completion-in-the-matlab-r2010a-editor\/"},"modified":"2010-03-22T15:21:14","modified_gmt":"2010-03-22T15:21:14","slug":"tab-completion-in-the-matlab-r2010a-editor","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2010\/03\/22\/tab-completion-in-the-matlab-r2010a-editor\/","title":{"rendered":"Tab Completion in the MATLAB R2010a Editor"},"content":{"rendered":"<p>In continuing our coverage of the new MATLAB R2010a desktop features, this week I&#8217;m highlighting the updates to Tab Completion. For those new to this feature, anytime I refer to &#8220;Tab&#8221; I mean the TAB key on a keyboard, and not the open file tabs in the Editor. Using Tab Completion in the Command Window or Editor is easy: type the first few letters of a word and press the Tab key to bring up a list of all stuff MATLAB recognizes that starts with the typed letters. If only one match is found, the rest of the word is automatically completed, if more than 1 match is found, a window is shown to make a selection. If no matches are found, the window will display a message to that effect.<\/p>\n<p>Go ahead and try it out; you may have to turn it on in the preferences: File -> Preferences -> Keyboard<\/p>\n<div align=\"center\">\n<img decoding=\"async\" border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/michael_katz_tab_completion\/tab_preferences.png\" alt=\"Tab Completion Preference\">\n<\/div>\n<p>Before R2010a, Tab Completion listed the same set of words in both the Editor and Command Window: functions on the path, variables in the workspace, fields\/methods\/properties of objects in the workspace, and inputs for a small subset of functions such as file names and figure properties. Because the Editor&#8217;s completion mechanism was based off the workspace, a common workflow was: run a file or part of a file with &#8220;eval selection&#8221;, cell mode, or using a breakpoint to put local variables into the workspace in order to get Tab completion of those variables. Another common workflow to insert variable names was to use copy &#038; paste within the Editor, or type out the variable names, both of which can introduce bugs.<\/p>\n<p>Well&#8230;. not anymore! In this release, the Editor has added smarts to recognize variable names and subfunctions within the scope of where you&#8217;re editing. The editor analyzes the syntax and structure of your file to figure out what might be a variable or subfunction and where it can be used. <\/p>\n<div align=\"center\">\n<img decoding=\"async\" border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/michael_katz_tab_completion\/tab_completion.png\" alt=\"Tab Completion example\">\n<\/div>\n<p>There are a few limitations to this feature. Because the completion list comes from analyzing the file&#8217;s syntax, the code must by reasonably syntactically correct. It doesn&#8217;t have to be perfect, but there are forms of bad files that can&#8217;t be analyzed. Another limitation comes from MATLAB&#8217;s dynamic data-types. Because tab completion uses static analysis, it doesn&#8217;t try to guess at the data type for a variable, so things after a &#8220;.&#8221; such as properties and fields won&#8217;t be completed unless that variable is also defined in the workspace. For similar reasons, variables created through <tt>eval<\/tt>, <tt>assignin<\/tt>, <tt>load<\/tt>, etc. won&#8217;t be added to the list of completions.<\/p>\n<p>I know longtime reader <a href=\"https:\/\/blogs.mathworks.com\/community\/2010\/03\/08\/new-and-updated-features-in-r2010a\/#comment-6922\">Daniel<\/a> was fired up about this new feature. What do you think? Will you now be more likely to use Tab Completion in your workflow?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In continuing our coverage of the new MATLAB R2010a desktop features, this week I&#8217;m highlighting the updates to Tab Completion. For those new to this feature, anytime I refer to&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2010\/03\/22\/tab-completion-in-the-matlab-r2010a-editor\/\">read more >><\/a><\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/370"}],"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\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=370"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/370\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}