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

Tidy code layout with Format Document - Visual Studio Code Tutorial

From the course: Visual Studio Code Productivity Tips

Start my 1-month free trial

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