In settings.json
it is possible to only format *.ts
files with:
"[typescript]": {
"editor.formatOnSave": true
}
but I can't get it to work for *.tsx
files.
To automatically format the file on save, In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option. Search for format on save setting and check the checkbox.
VS Code has great support for source code formatting. The editor has two explicit format actions: Format Document (Ctrl+Shift+I) - Format the entire active file. Format Selection (Ctrl+K Ctrl+F) - Format the selected text.
"[typescriptreact]": {
"editor.formatOnSave": true
}
See also Language specific editor settings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With