If you want to beautify the code, you can just press Ctrl+Shift+P and type format code or press Alt+Shift+F

It correctly indents my code so it seems like that is what you are looking for, if not you might want to give an example.

Answer from Dick van den Brink on Stack Overflow
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
JS Beautify - Visual Studio Marketplace
Extension for Visual Studio Code - A little wrapper around "js-beautify" for conveniently beautifying CSS/HTML/JS files.
🌐
Carl de Souza
carldesouza.com › home › posts › how to beautify a javascript file in visual studio code
How to Beautify a JavaScript File in Visual Studio Code - Carl de Souza
September 11, 2020 - We can see the function is on one line: Search for and select Beautify: Click Install: Now, select CTRL + SHIFT + P or the View menu to bring up the Command Palette: Search for Beautify and you will see: Beautify …
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Beautify - Visual Studio Marketplace
Extension for Visual Studio Code - Beautify code in place for VS Code
🌐
W3Schools
w3schools.io › editor › vscode-format-code
How to format or beautify code in Visual Studio Code tutorials - w3schools
... These documents format the entire file. ... Go to File > Preferences >settings window opened, Select Workspaces. ... { "beautify.onSave": true, "editor.formatOnSave": true, "beautify.JSfiles": [ "js", "json", "jsbeautifyrc", "jshintrc", "ts" ] }
Find elsewhere
🌐
GitHub
github.com › HookyQR › VSCodeBeautify
GitHub - HookyQR/VSCodeBeautify: Enable js-beautify (https://github.com/beautify-web/js-beautify) in VS Code
You can control which file types, extensions, or specific file names should be beautified with the beautify.language setting. { "beautify.language": { "js": { "type": ["javascript", "json"], "filename": [".jshintrc", ".jsbeautifyrc"] // "ext": ["js", "json"] // ^^ to set extensions to be beautified using the javascript beautifier }, "css": ["css", "scss"], "html": ["htm", "html"] // ^^ providing just an array sets the VS Code file type } }
Starred by 605 users
Forked by 184 users
Languages   JavaScript
🌐
YouTube
youtube.com › watch
- YouTube
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
GitHub
github.com › francismeynard › vs-code-js-beautify-extension
GitHub - francismeynard/vs-code-js-beautify-extension: This is a code formatter settings almost similar to Eclipse java code formatter using js-beautify
This is a code formatter settings almost similar to Eclipse java code formatter using js-beautify - francismeynard/vs-code-js-beautify-extension
Author   francismeynard
🌐
GitHub
github.com › Unibeautify › vscode
GitHub - Unibeautify/vscode: Unibeautify for VSCode
For example, the .vscode/settings.json below adds the .myphp file extension to the php language identifier: ... By default all languages supported by Unibeautify will be enabled. You can disable a specific language by setting the language options to false as shown below. Important: You must restart/reload VSCode after enabling/disabling a language. ... --- CSS: false # Disable CSS! JavaScript: # Enable TypeScript beautifiers: ["Prettier"] # Enable beautifiers indent_style: "space" indent_size: 2
Starred by 120 users
Forked by 14 users
Languages   TypeScript 92.8% | JavaScript 4.1% | PHP 2.4%
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
JsPrettier · vim-prettier neoformat ALE coc-prettier · JavaScriptPrettier · prettier-vscode · Built-in support · Got more?Send a PR · See others · Regularly used by: More than 83% of respondents to State of JS 2021. More than 70% of respondents to State of JS 2020.
🌐
Beautifier
beautifier.io
Online JavaScript beautifier
End script and style with newline? Support e4x/jsx syntax Use comma-first list style? Detect packers and obfuscators? (unsafe) Preserve inline braces/code blocks? Keep array indentation? Break lines on chained methods? Space before conditional: "if(x)" / "if (x)" Unescape printable chars encoded ...
Top answer
1 of 16
5994

The code formatting is available in Visual Studio Code through the following shortcuts:

  • On Windows Shift + Alt + F
  • On Mac Shift + Option + F
  • On Linux Ctrl + Shift + I

Alternatively, you can find the shortcut, as well as other shortcuts, through the submenu View / Command Palette, also provided in the editor with Ctrl +Shift+ P (or Command + Shift + P on Mac), and then searching for format document.

For unsaved snippets

  1. Open command palette (Win: F1 or Ctrl+Shift+P)

  2. Find "Change Language Mode"

  3. Select language e.g. json. By now syntax should be highlighted.

  4. Format document (e.g. Open Command Palette -> "Format Document")

Unformat

  1. Select text
  2. Command Palette -> Join Lines

'Show the pics'

2 of 16
606

Code Formatting Shortcut:

Visual Studio Code on Windows - Shift + Alt + F

Visual Studio Code on MacOS - Shift + Option + F

Visual Studio Code on Ubuntu - Ctrl + Shift + I

You can also customize this shortcut using a preference setting if needed.

Code Formatting While Saving the File:

Visual Studio Code allows the user to customize the default settings.

If you want to auto format your content while saving, add the below code snippet in the work space settings of Visual Studio Code.

Menu FilePreferencesWorkspace Settings

{
  // Controls if the editor should automatically format the line after typing
  "beautify.onSave": true,

  "editor.formatOnSave": true,

  // You can auto format any files based on the file extensions type.
  "beautify.JSfiles": [
      "js",
      "json",
      "jsbeautifyrc",
      "jshintrc",
      "ts"
  ]
}

Note: now you can auto format TypeScript files. Check my update.

🌐
Chocolatey
community.chocolatey.org › packages › vscode-beautify
Chocolatey Software | Beautify VSCode Extension 1.5.0
This extension enables running js-beautify in VS Code, AND honouring any .jsbeautifyrc file in the open file's path tree to load your code styling. Run with F1 Beautify (to beautify a selection) or F1 Beautify file. This package requires Visual Studio Code 1.22.0 or newer. You can install either the vscode or vscode-insiders package.
🌐
StackShare
stackshare.io › stackups › js-beautifier-vs-prettier
JS Beautifier vs Prettier | What are the differences?
Pros of JS Beautifier · Pros of Prettier · Be the first to leave a pro · 2Customizable · 1Open Source · 1Atom/VSCode package · 1Follows the Ruby Style Guide by default · 1Runs offline · 1Completely free · Sign up now ·