{"id":3213,"date":"2024-04-23T00:54:54","date_gmt":"2024-04-22T22:54:54","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=3213"},"modified":"2024-04-23T00:54:54","modified_gmt":"2024-04-22T22:54:54","slug":"how-to-prevent-visual-studio-code-from-automatically-organizing-or-sorting-our-imports-on-save","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2024\/04\/23\/how-to-prevent-visual-studio-code-from-automatically-organizing-or-sorting-our-imports-on-save\/","title":{"rendered":"How to prevent Visual Studio Code from automatically organizing or sorting our imports on save"},"content":{"rendered":"\n<p>To prevent Visual Studio Code from automatically organizing or sorting our imports on save, we can disable the corresponding setting in the editor configuration. Here&#8217;s how we can do it:<\/p>\n\n\n\n<ul><li>Open Visual Studio Code.<\/li><li>Go to the &#8220;Settings&#8221; by either clicking on the gear icon in the bottom left corner and selecting &#8220;Settings&#8221; or by using the shortcut Ctrl + , (Cmd + , on Mac) to open the settings.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2024\/04\/image-7.png\" alt=\"\" class=\"wp-image-3214\" width=\"482\" height=\"441\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2024\/04\/image-7.png 595w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2024\/04\/image-7-300x274.png 300w\" sizes=\"(max-width: 482px) 100vw, 482px\" \/><\/figure><\/div>\n\n\n\n<ul><li>In the search bar at the top of the settings,  type &#8220;editor.codeActionsOnSave&#8221;.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2024\/04\/image-8.png\" alt=\"\" class=\"wp-image-3215\" width=\"652\" height=\"168\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2024\/04\/image-8.png 811w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2024\/04\/image-8-300x77.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2024\/04\/image-8-768x198.png 768w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><\/figure><\/div>\n\n\n\n<ul><li>Look for the setting Editor: Code Actions On Save and click on &#8220;Edit in settings.json&#8221;<\/li><li>Add the following configuration to the settings.json file:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\"editor.codeActionsOnSave\": {\r\n    \"source.organizeImports\": false\r\n}\r\n<\/code><\/pre>\n\n\n\n<ul><li>Save the settings.json file.<\/li><\/ul>\n\n\n\n<p>After making this change, Visual Studio Code should no longer automatically organize or sort our imports when we save the file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To prevent Visual Studio Code from automatically organizing or sorting our imports on save, we can disable the corresponding setting in the editor configuration. Here&#8217;s how we can do it: Open Visual Studio Code. Go to the &#8220;Settings&#8221; by either clicking on the gear icon in the bottom left corner and selecting &#8220;Settings&#8221; or by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2307,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[252,251,81,249,838,299],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3213"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=3213"}],"version-history":[{"count":1,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3213\/revisions"}],"predecessor-version":[{"id":3216,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3213\/revisions\/3216"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/2307"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=3213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=3213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=3213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}