DEV Community

Cover image for Controlling Auto Semicolon in Visual Studio Code for CSS: A Quick Guide
Earid A.
Earid A.

Posted on

Controlling Auto Semicolon in Visual Studio Code for CSS: A Quick Guide

Visual Studio Code (VS Code) is a powerful and versatile code editor, widely used by developers for various programming languages, including HTML, CSS, and JavaScript. While it offers helpful features, some developers might find certain auto-completions intrusive or unnecessary. In this blog post, we will focus on one specific annoyance for CSS developers – the automatic insertion of semicolons after CSS properties – and explore how to disable this feature in VS Code.

Disabling Auto Semicolon in Visual Studio Code:

VS Code’s auto semicolon feature can be particularly bothersome for those who prefer not to have semicolons automatically added at the end of CSS properties. Fortunately, there are a couple of ways to disable this feature.

Option 1: Through the Visual Studio Code UI

Open Visual Studio Code.
Navigate to “Settings” by clicking on the gear icon in the bottom left corner or by pressing Ctrl + ,.
Click on “Extensions” in the sidebar.
Scroll down and find the “CSS” extension.
Look for the option labeled “Complete Property With Semicolon” and uncheck it.
Option 2: Using the Settings Editor

Open the Settings editor by pressing Ctrl + , and clicking on the open settings icon in the top right corner.
In the search bar, type “Complete Property With Semicolon” to quickly locate the relevant setting.
Change the value from true to false.

// Insert semicolon at the end of the line when completing CSS properties
"scss.completion.completePropertyWithSemicolon": false,
Enter fullscreen mode Exit fullscreen mode

Exploring the Configuration File:

For those who prefer a more hands-on approach or want to document these changes in a configuration file, it’s possible to modify the settings.json file directly. This file holds various configurations for VS Code.

Open the command palette by pressing Ctrl + Shift + P and type “Preferences: Open Settings (JSON)”.
Add or modify the following configuration to disable the auto semicolon feature:

// Insert semicolon at the end of the line when completing CSS properties
"scss.completion.completePropertyWithSemicolon": false,
Enter fullscreen mode Exit fullscreen mode

By following these simple steps, you can regain control over the auto semicolon feature in Visual Studio Code for CSS. Whether you choose to disable it through the UI or directly edit the configuration file, the flexibility of VS Code allows developers to customize their coding environment to suit their preferences.
Happy coding!

Top comments (0)