Answer a question

I downloaded Visual Studio Code thinking it would be nice to write T-SQL scripts and have the pretty auto-formatting happen as write.

I've already installed the mssql extension.

When creating a new file, the file is a simple plaintext with no extension 'Untitled-1'.

How in the world do I tell VS Code this is a SQL script so it formats correctly?

If I hit Shift+ALT+F, I simply receive the error "There is no formatter for 'plaintext' installed."

If I save the file with the extension '.sql', the format is applied.

However, I don't want to have to save the file... I want it to just be a scratchpad.

Is there any way in VS Code to tell the editor the file should be formatted SQL other than saving the file as an SQL file?

Thanks!

Answers

I hope this will be of some help to you.

If I understood you correctly, you can use first this shortcut:

Win: Ctrl+Shift+P / Mac: Cmd+Shift+p

And then type "Change Language Mode".

Also try and visit this link for additional info: https://marketplace.visualstudio.com/items?itemName=cymonk.sql-formatter

Also you can visit this link: https://code.visualstudio.com/docs/languages/overview where you can find additional info about that, for example:

Changing the language for the selected file

In VS Code, we default the language support for a file based on its filename extension. However, at times you may wish to change language modes, to do this click on the language indicator - which is located on the right hand of the Status Bar. This will bring up the Select Language Mode drop-down where you can select another language for the current file.

Tip: You can get the same drop-down by running the Change Language Mode command (Ctrl+K M).

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐