Code Formatting In Visual Studio Code

Posted on by

Language Support for Java(TM) by Red Hat also provides formatting settings. You can export an Eclipse formatter file and then use it for your project in VS Code.

In addition, there are also the Checkstyle for Java and SonarLint extensions, which provide features for live linting and code analysis.


Apply code styles For C# code files, Visual Studio 2019 has a Code Cleanup button at the bottom of the editor (keyboard: Ctrl + K, Ctrl + E) to apply code styles from an EditorConfig file or from the Code Style options page. If an.editorconfig file exists for the project, those are the settings that take precedence. Use the Formatting options page and its subpages (Indentation, New Lines, Spacing, and Wrapping) to set options for formatting code in the code editor. To access this options page, choose Tools Options from the menu bar. In the Options dialog box, choose Text Editor C# Code Style Formatting. Visual Studio Code has built in formatters for TypeScript, C# and Go, but I want formatters for html, scss and javascript as well. Visual Studio Code provides a formatting API, so other developers can create formatters for programming languages. There is a great blog article on how to write a. So far after installing the C extension tool, I can use Ctrl + K + F to auto-format my C code. However, I would like to make some modification, for example I would like to force the pointer alignment to be near the type, instead of next to the variable name, such as this rule: # Force pointers to the type for C.


With the Checkstyle for Java extension, you can use either existing checkstyle configurations (Google's or Sun's Check) or your own customized files for your project. When editing a Java file, the extension will check the file format and provide Quick Fixes if possible on the fly.

Set Checkstyle configuration file.

The Checkstyle for Java extension supports live linting.

And batch check.

The Problems panel will open when you click the Checkstyle status icon in the Status bar.

Set Checkstyle configuration file

  • To set the configuration file, right-click the .xml file and select Set the Checkstyle Configuration File.

  • You can also trigger the command Checkstyle: Set Checkstyle Configuration File to choose the configuration file in the File Explorer. The extension looks for a checkstyle.xml file in your workspace to make Checkstyle configuration easier. You will also see the two built-in configurations:

    • Google's Check
    • Sun's Check
  • Command Checkstyle: Set the Checkstyle Configuration detects potential Checkstyle configuration files and lists them. You can also provide a configuration file by directly writing a URL in the input box.

You can also set the Checkstyle version by using the command Checkstyle: Set the Checkstyle Version.

The command will:

  • List the latest Checkstyle version from the main repo.
  • List all the downloaded versions.
  • List all the supported versions.
  • Mark the currently used version with a check symbol.

In addition, you can also bring any 3rd-party modules for Checkstyle by configuring its path. For example, after using the configuration below, you can add <module name='SingleBreakOrContinueCheck'/> or <module name='com.github.sevntu.checkstyle.checks.naming.SingleBreakOrContinueCheck'/> to checkstyle.xml to leverage those checks.

Check the style and fix the violations

  • When editing a Java file, the extension will check the file format and provide Quick Fixes if possible. You can click the lightbulb button in the editor to show the available Quick Fixes.

For more details about Checkstyle for Java, visit its GitHub Repository.


The SonarLint extension lets you detect bugs and vulnerabilities as you write code in VS Code. Java is one of the languages supported, and the extension will run in the background and highlight source code that poses a quality or security concern.

C# Visual Studio Format Code

Code Analysis on the fly


Issues are highlighted directly in the editor with hovers to provide detailed explanations.

Issues found in the opened file can also be reviewed through the Problems panel of VS Code. When applicable, secondary code locations are mentioned so you can understand where the issue originates from (for example, the code path that led to a bug).

Rule documentation and remediation guidance

For any issue detected, SonarLint provides full documentation about the rule that was violated, and the coding best practice it relates to. This lets you understand why an issue is raised, and most importantly how to best fix it.

Enabling more quality and security rules

By default, SonarLint provides a wide array of rules to detect bugs and vulnerabilities. More checks can be enabled through the SonarLint Rules view.

For more details about the SonarLint for VS Code extension, visit the SonarLint website.


Currently, you need an Eclipse formatter file like Google Style.

Set the following property:

The property can point to a URL or a local file path. Cisco anyconnect opensuse.

If the formatter XML file contains more than one profile, you can set the profile name:

Reformat Code In Visual Studio Code

You can also define the formatting preferences in your project's .settings/org.eclipse.jdt.core.prefs. It will override the global formatting settings.

Visual Studio Format Code Shortcut

We are working on a solution to allow editing your formatting preferences from within VS Code. For now, the best way to edit them is to use Eclipse. See Formatter Settings for details.

Code Formatting In Visual Studio Code

An opinionated Blade file formatter for VSCode. Marketplace page is here.

You can also format by same syntax programmatically with blade-formatter that this extension relies on.


  • Automatically Indents markup inside directives
  • Automatically add spacing to blade templating markers
  • PHP 8 support (null safe operator, named arguments) 🐘
  • PSR-2 support (format inside directives)


Extension Settings

Blade Formatter: format EnabledWhether it enables or nottrue
Blade Formatter: format Indent SizeAn indent size4
Blade Formatter: format Wrap Line LengthThe length of line wrap size120
Blade Formatter: format Wrap AttributesThe way to wrap attributes. [auto force force-aligned force-expand-multiline aligned-multiple preserve preserve-aligned]auto

Ignoring Files: .bladeignore

To exclude files from formatting, create .bladeignore file in the root of your project .bladeignore uses gitignore syntax


  • [ ] Add more option for HTML formatting rules
  • [ ] Add option for PHP formatting rules
  • [x] Automate package publishing flow
  • [x] Integration test

Release Notes



  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request