{"id":2032,"date":"2024-03-05T12:18:58","date_gmt":"2024-03-05T17:18:58","guid":{"rendered":"https:\/\/blogs.mathworks.com\/matlab\/?p=2032"},"modified":"2024-03-05T12:19:28","modified_gmt":"2024-03-05T17:19:28","slug":"matlab-extension-for-visual-studio-code-now-with-code-execution","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/matlab\/2024\/03\/05\/matlab-extension-for-visual-studio-code-now-with-code-execution\/","title":{"rendered":"MATLAB extension for Visual Studio Code: Now with code execution"},"content":{"rendered":"<div class = rtcContent><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Back in April last year, I announced the MATLAB extension for Visual Studio Code <\/span><span> <\/span><span>on The MATLAB Blog and everyone at MathWorks was blown away by its popularity. In less than a year there have been over 150,000 installs of the <\/span><a href = \"https:\/\/marketplace.visualstudio.com\/items?itemName=MathWorks.language-matlab\" target=\"_blank\"><span style=' text-decoration: underline;'>MATLAB extension via the Visual Studio Marketplace<\/span><\/a><span>, the announcement blog post is one of the most popular blogs across all of MATLAB Central and <\/span><span>there has been a lot of active discussion on the <\/span><a href = \"https:\/\/github.com\/mathworks\/matlab-extension-for-vscode\" target=\"_blank\"><span style=' text-decoration: underline;'>extension\u2019s GitHub repository<\/span><\/a><span> including enhancement requests and bug reports. It\u2019s safe to say that it has been a great success.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>If you are new here and are wondering what all the fuss is about with respect to MATLAB and Visual Studio Code, you can check out <\/span><a href = \"https:\/\/www.youtube.com\/watch?v=kYTBAr9LlGg\" target=\"_blank\"><span style=' text-decoration: underline;'>this YouTube video<\/span><\/a><span> alongside reading <\/span><a href = \"https:\/\/blogs.mathworks.com\/matlab\/2023\/04\/26\/do-you-use-visual-studio-code-matlab-is-now-there-too\/\"><span>my original blog post announcing the release of the first version<\/span><\/a><span>. Today\u2019s post will focus on what\u2019s new.<\/span><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>Pull requests are welcome<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Split into two repositories,<\/span><a href = \"https:\/\/github.com\/mathworks\/MATLAB-extension-for-vscode\" target=\"_blank\"><span>MATLAB-extension-for-vscode<\/span><\/a><span> and <\/span><a href = \"https:\/\/github.com\/mathworks\/MATLAB-language-server\" target=\"_blank\"><span>MATLAB-language-server<\/span><\/a><span>, the project has been available on GitHub since the beginning and community contribution is encouraged. It has been great to see contributions from people outside of MathWorks including <\/span><a href = \"https:\/\/github.com\/tiagovla\" target=\"_blank\"><span>Tiago Vilela<\/span><\/a><span>, who used the MATLAB Language server to provide <\/span><a href = \"https:\/\/github.com\/mathworks\/MATLAB-language-server\/issues\/4\" target=\"_blank\"><span>MATLAB support for the Neovim editor<\/span><\/a><span>. <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/github.com\/mathworks\/MATLAB-language-server\/issues\/4\" target=\"_blank\"><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/03\/VSCodeRun_1.png\" width = \"301\" height = \"255\" alt = \"\" style = \"vertical-align: baseline; width: 301px; height: 255px;\"><\/img><\/a><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>We've also had pull requests from <\/span><a href = \"https:\/\/github.com\/doronbehar\" target=\"_blank\"><span>Doron Behar<\/span><\/a><span> and <\/span><a href = \"https:\/\/github.com\/MoetaYuko\" target=\"_blank\"><span>Moeta Yuko<\/span><\/a><span> fixing various things. Thank you so much to everyone who has contributed so far and we look forward to more collaboration with the community.<\/span><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>Listening to your feedback<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Being a developer, product manager or advocate of any popular piece of software can be a wild ride emotionally. On the one hand, you get great feedback like this<\/span><span> <\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/03\/VSCodeRun_2.png\" width = \"512\" height = \"131\" alt = \"Screenshot 2024-02-26 172419.png\" style = \"vertical-align: baseline; width: 512px; height: 131px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Positive with a side order of constructive suggestion, something we can work with. We received many comments like this in social media, via email and in one to one discussions with users. However, we also received a few comments like this.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/03\/VSCodeRun_3.png\" width = \"625\" height = \"83\" alt = \"waste_of_time.png\" style = \"vertical-align: baseline; width: 625px; height: 83px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Ouch! Clearly, we fell way below this user\u2019s expectations and we are sorry that the first release may have come up short for some users. We didn\u2019t want to allow \u201cperfect\u201d to be the enemy of \u201cgood\u201d and we felt the first release had a lot of useful functionality, so we released it into the wild. Our goal was to provide a solid foundation that could be built upon quickly in collaboration with the community and it's working! Over 150,000 users so far, contributions from the community and fast iteration on bug fixes. There have been <\/span><a href = \"https:\/\/marketplace.visualstudio.com\/items\/MathWorks.language-matlab\/changelog\" target=\"_blank\"><span>10 updates since the first release<\/span><\/a><span> in less than a year. We are really happy with these results.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>With that said, the lack of code execution from within Visual Studio Code was a common complaint among users, even among MathWorkers. It was also <\/span><a href = \"https:\/\/github.com\/mathworks\/MATLAB-extension-for-vscode\/issues\/4\" target=\"_blank\"><span>one of the first things requested on the project's GitHub issues page<\/span><\/a><span>. Everyone wanted it!<\/span><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>Giving you what you want: MATLAB code execution from Visual Studio Code<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>So now we've got it. Ensure that you've installed at least version 1.2.0 of the <\/span><a href = \"https:\/\/marketplace.visualstudio.com\/items?itemName=MathWorks.language-matlab\" target=\"_blank\"><span>MATLAB extension for Visual Studio Code<\/span><\/a><span> alongside a copy of MATLAB that's at R2021a or above and you can run MATLAB programs right from Visual Studio Code.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/03\/VSCodeRun_4.gif\" width = \"649\" height = \"405\" alt = \"RunVSCode1.gif\" style = \"vertical-align: baseline; width: 649px; height: 405px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>As you can see, just push the run button and your code will run in the MATLAB terminal. You can either continue editing or interact with the terminal further, whatever suits you best at the time. <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Plots are rendered in a separate window, exactly as if you had run them from MATLAB Desktop.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span> <\/span><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/03\/VSCodeRun_5.gif\" width = \"649\" height = \"404\" alt = \"VSCode_plot.gif\" style = \"vertical-align: baseline; width: 649px; height: 404px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Speaking of MATLAB Desktop, you can access that at any time by typing <\/span><span style=' font-family: monospace;'>desktop<\/span><span> into the Visual Studio Code MATLAB terminal. It will be connected to the same workspace you are using from Visual Studio Code.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/03\/VSCodeRun_6.png\" width = \"829\" height = \"394\" alt = \"\" style = \"vertical-align: baseline; width: 829px; height: 394px;\"><\/img><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>What we haven't given you: Debugging<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>The addition of code execution to the MATLAB extension for Visual Studio Code makes it much more useful and we hope you'll like it. The next obvious thing to request is debugging support and, if this important to you, please do add your voice to the discussion over at <\/span><a href = \"https:\/\/github.com\/mathworks\/MATLAB-extension-for-vscode\/issues\" target=\"_blank\"><span>the issues section on GitHub<\/span><\/a><span> along with everything else that you'd like.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>The team are enjoying developing and delivering this functionality to you and we look forward to seeing you play with it, discussing it and letting us know what you want next! <\/span><\/div>\n<\/div><script type=\"text\/javascript\">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/matlab\/files\/2024\/03\/VSCodeRun_4.gif\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>Back in April last year, I announced the MATLAB extension for Visual Studio Code  on The MATLAB Blog and everyone at MathWorks was blown away by its popularity. In less than a year there have been... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/matlab\/2024\/03\/05\/matlab-extension-for-visual-studio-code-now-with-code-execution\/\">read more >><\/a><\/p>","protected":false},"author":176,"featured_media":2056,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,64],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/2032"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/users\/176"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/comments?post=2032"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/2032\/revisions"}],"predecessor-version":[{"id":2068,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/2032\/revisions\/2068"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media\/2056"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media?parent=2032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/categories?post=2032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/tags?post=2032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}