Issue #16  (Whitespace Characters)08/10/22

Advertisement
Get a weekly dose of tools, articles, and other resources covering remote work, productivity, career well-being, and lots more.

VS Code has a few different settings that allow you to control the visibility and even the existence of whitespace characters. It will depend on what your preference is and what type of code you're writing, but you may strongly prefer to change the defaults in this instance.

If you type "whitespace" in your Settings search box, you'll see a number of options show up. Probably the most useful of the whitespace-related settings is the Render Whitespace option, which has five possible values.

Rendering whitespace in VS Code

Setting this to "all" will cause your files to essentially look like the screenshot shown below where I've added some arrows to show where some of the characters are:
 
Rendering all whitespace in VS Code

Notice the dot characters that appear everywhere that there's no physical character. There are some trailing dot characters, indicating trailing whitespace, and there are even dots to indicate single whitespace characters between words. This might be overkill so you can choose one of the other options:
  • boundary – Renders all whitespace characters except single spaces between words
  • selection – The default setting, rendering whitespace only on selected text.
  • trailing – Only renders trailing whitespace
Another pair of useful whitespace-related settings have to do with removing trailing whitespace. Firstly, if you're still looking at the search results for "whitespace", you'll see an option to "Trim Trailing Whitespace". This is off by default, but turning it on will remove any trailing whitespace when the file is saved.
 
Trailing whitespace characters

This means all lines in the file that include any trailing whitespace characters (as shown in the image above) will be deleted. Such characters might creep in from copying and pasting from somewhere online, or even in an old inherited project.

The only thing this won't remove is trailing new lines, which can also creep in, sometimes just from naturally hitting enter/return multiple times at the end of a file. This setting doesn't show up using the "whitespace" keyword search. You'll have to search for "Trim Final Newlines" to find this one. This will automatically remove trailing newlines, as shown in the following image.

Trailing newlines

The setting will remove all but one of the trailing new lines, which is good. I personally like to have those trailing lines and characters removed from my files, so these are definitely settings I keep on. Along with the option to autosave files, trailing whitespace characters and lines will hardly even be noticed in most cases.

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

 

VS Code Tools

VS Code Counter — VS Code extension that counts blank lines, comment lines, and physical lines of source code in multiple programming languages.

GitHub Pull Requests and Issues — A popular VS Code extension that lets you review and manage your GitHub pull requests and issues directly in VS Code.

Fortnite VS Code Theme — A VS Code theme inspired by the popular video game series by the same name.

Error Lens — A VS Code extension that provides highlighting of errors, warnings, and other language diagnostics.

VS Code Articles

A Complete Guide to VS Code Extension Testing — If you're an extension developer or thinking about getting into this space, this might be a post you'll want to save.

Setting Up VSCode on Tablet/Phones — I'm guessing not many will need these instructions, but in case you do have such a use case, this might help.

VS Code and Python: A Natural Fit for Data Science — Lots of data here on why these two technologies are such a good fit if you happen to be in the data science niche.

PostApex: Advertise in Premium Email Newsletters — A premium email advertising platform that lets you reach over 100 million readers across the world. You can discover email newsletters that fit your customer profile and effortlessly launch newsletter sponsorships.   Sponsor 

The Alternatives

I Stopped Using Visual Studio Code — The author recently switched to WebStorm, so this is a big plug for that IDE if you're looking for a reason to switch, or even just to use as a new secondary IDE.

Rety — A library that's useful for live presentations that allows you to record edits made on code snippets, after which you can replay them later to recreate the same typing flow.

Playcode — A new JavaScript playground with a focus on learning the language. It lets you install npm packages, has a super-fast live view, and code autocomplete.


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.