Force Hero
Force Hero

Reputation: 3202

How do I change the linter/formatter in VS Code?

I'm on Ubuntu. Pushing Ctrl + Shift + i in VS Code auto formats the file.

I was editing a solidity contract and pushed Ctrl + Shift + i, VS Code didn't have a formatter configured so it asked me to pick one - I accidentally chose my JS prettifier extension instead of the solidity one. This badgered up my code by trying to use single quotes instead of double quotes (not allowed in solidity) and some other non-solidity friendly changes.

Pushing Ctrl + Shift + i now just auto formats with the wrong formatter with no option to pick a different one.

How can I change which linter/formatter is associated to which file types in VS Code?

Upvotes: 3

Views: 12708

Answers (1)

Jacopo Mosconi
Jacopo Mosconi

Reputation: 1042

Solution A:

Press Ctrl+Shift+P

Then type Format Document With...

At the end of the list click on Configure Default Formatter...

Now you can choose your favorite beautifier from the list.

Solution B:

go to file -> preferences -> settings search for format, on the left side, click on Text Editor, the very first item on the right side is Editor: Default Formatter from the dropdown you can pick any document formatter which you installed before.

Upvotes: 5

Related Questions