From the course: Visual Studio Code Productivity Tips
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Tidy code layout with Format Document - Visual Studio Code Tutorial
From the course: Visual Studio Code Productivity Tips
Tidy code layout with Format Document
- [Instructor] Check out the code in this example in this formatcode.js file. There are many layout and readability issues. For example, on line 12 there's this mysterious extra space between the variable and the equal sign. Now I can fix this manually by removing that text, but there's no reason to waste time manually moving text around on the screen to get it arranged the way you want when there are formatting tools to handle the job. So the first formatting tool we'll look at is format document and format selection, but before I do that let's talk about what's wrong with this document. Here on line four there's an extra space between the zero and the semicolon. That's inconsistent with the other lines of variable declarations. Line five, where I declare the variable results, is indented differently than the rest of the variables. Line six has a four loop, the arguments for the four loop are tightly shoved together, which makes it harder to read. And we've already talked about line…
Contents
-
-
-
Use Go to and Peek Definition to find code references4m 29s
-
Refactor the code4m 12s
-
Favorite extensions: Bracket Pair Colorizer2m 53s
-
Tidy code layout with Format Document6m 54s
-
Favorite extensions: XML Tools2m 36s
-
Create custom keybindings for common commands2m 40s
-
Favorite extensions: Spell Checker2m 40s
-
A simple technique to copy code blocks1m 1s
-
Favorite extensions: Sort lines2m 2s
-
Use Emmet notation to add boilerplate text6m 14s
-
Favorite extensions: GitLens4m 24s
-
Use font ligatures to add symbols to your code2m 46s
-
-