{"id":41660,"date":"2022-05-26T09:00:40","date_gmt":"2022-05-26T08:00:40","guid":{"rendered":"https:\/\/arquiconsult.com\/?p=41660"},"modified":"2024-10-23T13:48:53","modified_gmt":"2024-10-23T12:48:53","slug":"how-to-create-al-snippets-in-visual-studio-code","status":"publish","type":"post","link":"https:\/\/arquiconsult.com\/es\/how-to-create-al-snippets-in-visual-studio-code\/","title":{"rendered":"#020 HOW TO CREATE AL SNIPPETS IN VISUAL STUDIO CODE"},"content":{"rendered":"<div class=\"services_vertical horizontal_services row\" style=\"background-color: #f7f7f7; padding: 25px; border-radius: 5px; text-align: justify;\">\n<p>Snippets are templates of code to optimize our work when programming in Visual Studio Code. After installing the AL Language extension, you get the common list of available Snippets as for example: tcodeunit, tfield, ttable. But what if you want to build your own Snippets? In this article we will explain how to do it.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p>To create a new Snippet, you can follow the steps below:<\/p>\n<p>1. Go to File &gt; Preferences &gt; User Snippets<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-41662 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Go-to-File-Preferences-User-Snippets-386x480.png\" alt=\"Go to File-Preferences-User Snippets\" width=\"386\" height=\"480\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Go-to-File-Preferences-User-Snippets-386x480.png 386w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Go-to-File-Preferences-User-Snippets.png 593w\" sizes=\"(max-width: 386px) 100vw, 386px\" title=\"-\"><\/p>\n<p>2. Select New Global Snippets file<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-41665 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Select-New-Global-Snippets-file-640x89.png\" alt=\"Select New Global Snippets file\" width=\"640\" height=\"89\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Select-New-Global-Snippets-file-640x89.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Select-New-Global-Snippets-file-768x107.png 768w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Select-New-Global-Snippets-file.png 1267w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<p>3. Give a name to your Snippet file<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-41668 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Give-a-name-to-your-Snippet-file-640x123.png\" alt=\"Give a name to your Snippet file\" width=\"640\" height=\"123\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Give-a-name-to-your-Snippet-file-640x123.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Give-a-name-to-your-Snippet-file-768x147.png 768w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/Give-a-name-to-your-Snippet-file.png 1266w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<p>4. A new file will be created, and it will be possible to define the Snippet structure in there. It must contain a prefix, which is the name that you will use to select your Snippet when coding, and a body, where you will write the Snippet itself.<\/p>\n<p>After saving the Snippet, it can be used in the code, like in the example below:<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-41674 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/After-saving-the-Snippet-it-can-be-used-in-the-code-like-in-the-example-below-640x379.png\" alt=\"After saving the Snippet, it can be used in the code, like in the example below\" width=\"640\" height=\"379\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/After-saving-the-Snippet-it-can-be-used-in-the-code-like-in-the-example-below-640x379.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/After-saving-the-Snippet-it-can-be-used-in-the-code-like-in-the-example-below-768x454.png 768w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/After-saving-the-Snippet-it-can-be-used-in-the-code-like-in-the-example-below.png 1268w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<p>5. The structure of the new table is automatically populated with the Snippet definition.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-41677 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/The-structure-of-the-new-table-is-automatically-populated-with-the-Snippet-definition.-369x480.png\" alt=\"The structure of the new table is automatically populated with the Snippet definition.\" width=\"369\" height=\"480\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/The-structure-of-the-new-table-is-automatically-populated-with-the-Snippet-definition.-369x480.png 369w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/05\/The-structure-of-the-new-table-is-automatically-populated-with-the-Snippet-definition..png 515w\" sizes=\"(max-width: 369px) 100vw, 369px\" title=\"-\"><\/p>\n<p>The Snippet files are stored, by default, in the following folder:<\/p>\n<p>C:\\Users\\UserName\\AppData\\Roaming\\Code\\User\\snippets<\/p>\n<p>In case you want to share or copy a Snippet, you can do it accessing the folder directly.<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-41660\" data-postid=\"41660\" class=\"themify_builder_content themify_builder_content-41660 themify_builder tf_clear\">\n    \t<!-- module_row -->\n\t<div  data-lazy=\"1\" class=\"module_row themify_builder_row tb_nus1581 tb_first tf_clearfix\">\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_cai8581 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module text -->\n<div  class=\"module module-text tb_9tkr581 arquitps-data  \" data-lazy=\"1\">\n        <div  class=\"tb_text_wrap\">\n    <p><script>\njQuery(\".tbp_post_month:contains(Janeiro)\").html(\"January\");\n\njQuery(\".tbp_post_month:contains(Fevereiro)\").html(\"February\");\n\n\njQuery(\".tbp_post_month:contains(Mar\u00e7o)\").html(\"March\");\n\n\njQuery(\".tbp_post_month:contains(Abril)\").html(\"April\");\n\n\njQuery(\".tbp_post_month:contains(Maio)\").html(\"May\");\n\n\njQuery(\".tbp_post_month:contains(Junho)\").html(\"June\");\n\n\njQuery(\".tbp_post_month:contains(Julho)\").html(\"July\");\n\njQuery(\".tbp_post_month:contains(Agosto)\").html(\"August\");\n\njQuery(\".tbp_post_month:contains(Setembro)\").html(\"September\");\n\njQuery(\".tbp_post_month:contains(Outubro)\").html(\"October\");\n\njQuery(\".tbp_post_month:contains(Novembro)\").html(\"November\");\n\njQuery(\".tbp_post_month:contains(Dezembro)\").html(\"December\");\t\n\n\n\n<\/script><\/p>    <\/div>\n<\/div>\n<!-- \/module text -->\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t\t<!-- module_row -->\n\t<div  data-anchor=\"sucesso\" data-hide-anchor=\"1\" data-lazy=\"1\" class=\"module_row themify_builder_row sucesso repeat tb_has_section tb_section-sucesso tb_cfpa813 tf_clearfix\" >\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_ehl8813 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module buttons -->\n<div  class=\"module module-buttons tb_7jtg813 buttons-horizontal transparent popmake-24705 large circle tf_textc\" data-lazy=\"1\">\n    \t<div class=\"module-buttons-item tf_inline_b\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"ui builder_button tb_default_color\" >\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"tf_inline_b tf_vmiddle\">Give as a Feedback and Suggest Questions<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t    \t<\/div>\n\t<\/div>\n<!-- \/module buttons -->\n\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t<\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Snippets are templates of code to optimize our work when programming in Visual Studio Code. After installing the AL Language extension, you get the common list of available Snippets as for example: tcodeunit, tfield, ttable. But what if you want to build your own Snippets? In this article we will explain how to do it. [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":41683,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2065,2125],"tags":[2087,2093],"acf":[],"_links":{"self":[{"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/posts\/41660"}],"collection":[{"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/comments?post=41660"}],"version-history":[{"count":0,"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/posts\/41660\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/media\/41683"}],"wp:attachment":[{"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/media?parent=41660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/categories?post=41660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arquiconsult.com\/es\/wp-json\/wp\/v2\/tags?post=41660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}