Issue #63  (Format on Save & Prettier)07/05/23

Advertisement
Meco: An Inbox Designed for Reading NewslettersEnjoy your newsletters in a space built for mindful reading while giving your inbox space to breathe. It's easy to get set up and completely free!

If you're accustomed to working with VS Code's Format On Save option, there's a related option you'll want to be familiar with as well, especially if you work on a lot of large, inherited projects. But first a quick review of Format on Save.

Format on Save allows you to auto-format any file you're working in whenever you save the document. You can enable the feature by searching for "Format On Save" in your settings:
 
Format on Save in VS Code

You'll see three settings, one for the editor, one for enabling in notebooks, and another I'll describe below. In order for this setting to work, you have to enable some type of formatter for the language you're working in.

Look up "Formatter" in your settings and from there you can specify a default formatter. VS Code includes some built-in formatters, but likely you'll want to choose your own. Prettier is a popular option that many of you are probably already using.

Setting a Default Formatter in VS Code

Once that's enabled, saving a document will format the whole thing according to the rules of your formatter. It's generally recommended to specify different formatters for different languages, which you can do in VS Code's JSON settings. Below I've set Prettier as the default formatter for JavaScript, with no default formatter in general.

Defaing language-specific formatters in VS Code for JS/TS

As I mentioned at the beginning, the related option is Format On Save Mode, which allows you to specify whether Format On Save applies to the entire file or only the modifications made.

Format on Save Mode in VS Code

The latter value is useful if you're working on a big file that's inherited or it's another project that you don't own or generally work on, but you're just contributing. This way you can avoid the team needing to review a large pull request that's mostly just formatting corrections that weren't requested in the first place.

Now on to this week's hand-picked links!
 

VS Code Tools

SQL Explainer — VS Code extension that uses the OpenAI API to translate SQL queries into English so you can quickly understand what a query does without having to decipher SQL code.

rust-analyzer — VS Code extension that provides support for the Rust programming language, recommended over an older deprecated extension.

Material Design Palette Generator — VS Code extension that lets you generate a Material Design color palette inside the editor.

Bytes: Your Favourite JavaScript Newsletter — I subscribe to a lot of newsletters, but this is definitely one I look forward to. Entertaining with lots of cool and useful JavaScript coding tidbits, news, and tools.  Sponsor 

Power Mode — A set of customizations for VS Code that originally existed for other editors and was later ported to VS Code.


VS Code Theme of the Week

Bearded Theme — A popular set of VS Code themes that includes more than 30 theme variations, one or more of which I'm sure you'll love. Many of these a quite nice, including the "Coffee" theme shown below. 

Bearded Theme for VS Code

You can choose from Oceanic, Coffee and Cream (a light theme), Earth, Vivid Purple, and even Surprising Watermelon (which is surprisingly simple and elegant).

VS Code Articles

Visual Studio’s IntelliSense List Can Now Steer GitHub Copilot Code Completions — With the latest version of GitHub Copilot, changing your selection in Visual Studio’s IntelliSense list steers the GitHub Copilot with additional context about your code.

My Favorite VS Code Settings — Part of a series of posts by Silvestar Bistrović. In this one he details some of his unique VS Code customizations.

Web Tools Weekly — Your weekly dose of the latest and the greatest in tools for JavaScript, CSS, HTML, SVG, React, Node.js, Vue, Svelte, and more.   Sponsor 

VS Code Profiles: Optimize Your Coding Environment — An introduction to the new Profiles feature in VS Code, and all the different ways you can benefit and use them.

Best of the Rest

Plain Text Journaling — A journaling system that uses NeoVim, coreutils, and dateutils, and loosely based on Ryder Caroll’s Bullet Journal method.

Comic Mono — A monospace font based on the most hated font in the world, Comic Sans, forked from another similar project.

Introducing the MDN Playground: Bring Your Code to Life! — Mozilla announces a new coding playground on MDN that provides a simple way to preview HTML, CSS, and JavaScript.


Suggestions?

If you have any link suggestions, including a tool, article, or other resources related to VS Code or another IDE, send it via DM on X: @LouisLazaris or just hit reply on this email.

That's it for this issue.

Happy VS Coding!
Louis
VSCode.Email
@LouisLazaris
Copyright © VSCode.Email. All rights reserved.

Not affiliated with Microsoft, Visual Studio Code, or any of its trademarks.