{"id":211,"date":"2021-01-28T11:37:44","date_gmt":"2021-01-28T02:37:44","guid":{"rendered":"https:\/\/derrylab.com\/?p=211"},"modified":"2021-01-28T11:37:44","modified_gmt":"2021-01-28T02:37:44","slug":"my-quick-ways-to-auto-format-code-in-vscode","status":"publish","type":"post","link":"https:\/\/blog.derrylab.com\/index.php\/2021\/01\/28\/my-quick-ways-to-auto-format-code-in-vscode\/","title":{"rendered":"My Quick Ways to Auto Format Code in VSCode"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I don&#8217;t have much time to format my code to looks neat in VSCode (<code>Ctrl + Shift + I<\/code>), but the default formatting from Visual Code is not efficient for me. It makes the first bracket on function placed alone in one line. This makes my code longer!<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re used to using jump\/goto line number it may not a problem. But for me, I need to take a screenshot of my codes for my report and this bracket is eating up the screenshot space. I tried googling around and finally found that this formatting can be changed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Press <code>ctrl + comma<\/code> to open settings. Then search for &#8220;<code>fallback<\/code>&#8220;, you will find <code>C_Cpp.clang_format_fallbackStyle<\/code> like the picture below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"878\" height=\"443\" src=\"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2021\/01\/image.png?resize=878%2C443&#038;ssl=1\" alt=\"\" class=\"wp-image-216\" srcset=\"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2021\/01\/image.png?w=878&amp;ssl=1 878w, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2021\/01\/image.png?resize=300%2C151&amp;ssl=1 300w, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2021\/01\/image.png?resize=768%2C387&amp;ssl=1 768w\" sizes=\"auto, (max-width: 878px) 100vw, 878px\" \/><figcaption>Visual Studio Formatting Settings<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Change it from <code>\"Visual Studio\"<\/code> to <code>{ BasedOnStyle: Google, IndentWidth: 4 }<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also add the <code>ColumnLimit<\/code> option to prevent your code break to the next line because of the Google-style column limit. For example:<br><code>{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0 }<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So now, each time you have done so many edits in your code and you need to auto-format it, just press <code>Ctrl + Shift + I<\/code> to make it neat! \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I don&#8217;t have much time to format my code to looks neat in VSCode (Ctrl + Shift + I), but the default formatting from Visual Code is not efficient for me. It makes the first bracket on function placed alone in one line. This makes my code longer!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[4,5],"tags":[90,93,91,36,89,94,64,88,70],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-linux","category-programming","tag-auto-format","tag-coding-style","tag-google","tag-linux","tag-settings","tag-tips","tag-tutorial","tag-visual-studio-code","tag-vscode"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":40,"url":"https:\/\/blog.derrylab.com\/index.php\/2020\/04\/01\/how-to-view-pointer-as-array-in-visual-studio-code\/","url_meta":{"origin":211,"position":0},"title":"How to View Pointer as Array in Visual Studio Code","author":"derry","date":"April 1, 2020","format":false,"excerpt":"It is irritating when you have to write and memorize this syntax in the middle of debugging, but let me just put it in here for future use: *mypointer@10 Replace mypointer with your pointer name, and replace 10 with how much array you want to view. The ,h at the\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/blog.derrylab.com\/index.php\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1282,"url":"https:\/\/blog.derrylab.com\/index.php\/2022\/08\/01\/problem-when-building-old-openssl-version-on-the-new-system\/","url_meta":{"origin":211,"position":1},"title":"Problem When Building Old OpenSSL Version on The New System","author":"derry","date":"August 1, 2022","format":false,"excerpt":"The old OpenSSL seems to have a problem when built using a newer system. I got this problem when compiling OpenSSL 1.1.0f on my Ubuntu 22.04. derry@G14:~\/openssl-1.1.0f$ .\/config -d shared no-asm no-hw Operating system: x86_64-whatever-linux2 \"glob\" is not exported by the File::Glob module Can't continue after import errors at .\/Configure\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/blog.derrylab.com\/index.php\/category\/programming\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/08\/pexels-anamul-rezwan-1145434-scaled.jpg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/08\/pexels-anamul-rezwan-1145434-scaled.jpg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/08\/pexels-anamul-rezwan-1145434-scaled.jpg?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/08\/pexels-anamul-rezwan-1145434-scaled.jpg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/08\/pexels-anamul-rezwan-1145434-scaled.jpg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":423,"url":"https:\/\/blog.derrylab.com\/index.php\/2022\/03\/16\/easy-fix-when-pop-os-login-screen-shown-on-the-wrong-monitor\/","url_meta":{"origin":211,"position":2},"title":"Easy Fix when Pop-OS Login Screen Shown on The Wrong Monitor","author":"derry","date":"March 16, 2022","format":false,"excerpt":"I turned on my newly installed Pop OS and then suddenly the login screen is located on the left monitor. It's horrible! Because I put my left monitor into a vertical position, and the Pop OS login screen orientation is in horizontal mode. Therefore I had to tilt my head\u2026","rel":"","context":"In &quot;linux&quot;","block_context":{"text":"linux","link":"https:\/\/blog.derrylab.com\/index.php\/category\/linux\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/03\/arian-darvishi-wh-RPfR_3_M-unsplash.jpg?fit=1200%2C799&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/03\/arian-darvishi-wh-RPfR_3_M-unsplash.jpg?fit=1200%2C799&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/03\/arian-darvishi-wh-RPfR_3_M-unsplash.jpg?fit=1200%2C799&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/03\/arian-darvishi-wh-RPfR_3_M-unsplash.jpg?fit=1200%2C799&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2022\/03\/arian-darvishi-wh-RPfR_3_M-unsplash.jpg?fit=1200%2C799&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":235,"url":"https:\/\/blog.derrylab.com\/index.php\/2021\/06\/24\/this-makes-my-risc-v-trap-handler-does-not-work\/","url_meta":{"origin":211,"position":3},"title":"This Makes My RISC-V Trap Handler Does Not Work","author":"derry","date":"June 24, 2021","format":false,"excerpt":"I was working on a RISCV assembly when suddenly I got a weird issue.The exception does not get caught in the trap handler. I thought this was a QEMU bug on the RISCV target because the trap handler works on my other code.Then after a day of digging, I figured\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/blog.derrylab.com\/index.php\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4135,"url":"https:\/\/blog.derrylab.com\/index.php\/2024\/12\/09\/how-to-understand-javascript-basics-in-10-minutes\/","url_meta":{"origin":211,"position":4},"title":"How to Understand JavaScript Basics in 10 Minutes","author":"derry","date":"December 9, 2024","format":false,"excerpt":"This is the basics of JavaScript, the secret sauce that makes your web pages more interactive. We're going to cover the key topics so you won't end up in a coding coma\u2014because who has the time for an exhausting lecture when there's so much internet to explore? 1. What is\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/blog.derrylab.com\/index.php\/category\/programming\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2024\/12\/create-a-detailed-and-high-resolution-image-focusing-on-the-main.png?fit=1024%2C768&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2024\/12\/create-a-detailed-and-high-resolution-image-focusing-on-the-main.png?fit=1024%2C768&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2024\/12\/create-a-detailed-and-high-resolution-image-focusing-on-the-main.png?fit=1024%2C768&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2024\/12\/create-a-detailed-and-high-resolution-image-focusing-on-the-main.png?fit=1024%2C768&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2780,"url":"https:\/\/blog.derrylab.com\/index.php\/2023\/04\/25\/how-to-replace-string-in-files-without-text-editor-in-linux\/","url_meta":{"origin":211,"position":5},"title":"How to Replace String in Files without Text Editor in Linux","author":"derry","date":"April 25, 2023","format":false,"excerpt":"As a Linux user, it's important to know how to modify text files through the command line. One common scenario is changing a single line in a text file, such as enabling or disabling a feature. But what if the OS doesn't have any text editor installed at all? In\u2026","rel":"","context":"In &quot;linux&quot;","block_context":{"text":"linux","link":"https:\/\/blog.derrylab.com\/index.php\/category\/linux\/"},"img":{"alt_text":"pencil shavings","src":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2023\/04\/pexels-photo-1237647.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2023\/04\/pexels-photo-1237647.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2023\/04\/pexels-photo-1237647.jpeg?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2023\/04\/pexels-photo-1237647.jpeg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/blog.derrylab.com\/wp-content\/uploads\/2023\/04\/pexels-photo-1237647.jpeg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":5,"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/posts\/211\/revisions\/218"}],"wp:attachment":[{"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.derrylab.com\/index.php\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}