Whether you’re including a quick description, or just adding a note for yourself, comments help immensely during debugging. It’s always a good idea to use comments to your advantage.This makes it easier to know which part of the code does a particular function. If you’re naming modules or short lines of code, make it a habit in using descriptive titles rather than simply calling it module 1, module 2, etc.This comes in handy when you’re dealing with logic errors instead of syntax ones. If-Then statements or nested cases, for example, can benefit from this by making each alternative option visually distinguishable from one another. Although indentation isn’t necessary for a program to run, it can help debugging by compartmentalizing code into manageable modules.Prettier will now automatically format your document whenever you save it.Click on the new file button to create a config file.Select the root of your project on the left menu.Once you’re done, you can exit this menu.Īs you’ve configured Prettier to automatically format only when there’s a config file, you must create one for each project. You can edit specific Prettier settings depending on your preferences.Note that untitled files will still be formatted automatically even if this setting is checked. This prevents you from overwriting formatting options unintentionally. This is handy when you’re looking at downloaded code that may have its own formatting rules. This setting prevents Prettier from formatting documents without a config file. Make sure that the checkbox has been ticked. Scroll down until you find the line “Prettier: Require Config”.Type “Prettier” in the settings search bar.Make sure that the “Editor: Format On Save” option has been checked.Alternatively, Prettier may appear on the list as “esbenp.prettier-vscode”. Select “Prettier – Code Formatter” from the list. If there’s no default formatter or VS Code is using another formatter by default, press the dropdown arrow. On the Editor: Default Formatter setting, make sure that the selected extension is Prettier.This should bring up several formatting settings. Open the settings window by pressing “Ctrl +,” on PC or “⌘ +,” on Mac.Wait for the extension to finish the installation.īefore Prettier can begin to automatically format your document on save, you’ll have to set up the extension to activate the feature.Click on the Install button on the bottom right corner of the Prettier icon.In the search bar at the top of the menu, type in Prettier.Alternatively, you can press “Ctrl + Shit + x” for PC or “⌘ + ⇧ + x” on Mac. This is the icon that looks like four boxes. Click on the Extensions button located on the left menu.Prettier can be installed by doing the following: The most popular of these extensions is Prettier which provides a lot of formatting functionality to VS Code. Instead, this can be done by installing a formatting extension onto your VS Code application. VS Code doesn’t have a native command that formats your document on save. Save the file by pressing “⌘ + S” or by choosing “Save” from the File menu on the upper left corner of the window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |