Can I use VS Code formatting feature inside bash?

Viewed 21

To format a code file, let's say a Javascript file or an HTML file, open it in VS Code and press Ctrl + Shift + I.

Can I somehow use this feature in bash?

Is it possible to use code and pass it the file path and the command in terminal?

1 Answers

According to the documentation, VS Code uses js-beautify for HTML and JS formatting, so you could simply install that and use it directly in bash:

$ npm -g install js-beautify
$ js-beautify foo.js
Related