Visual Studio Code 与 SQL 格式 [英] Visual Studio Code vs SQL Formatting

查看:61
本文介绍了Visual Studio Code 与 SQL 格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了 Visual Studio Code,认为编写 T-SQL 脚本并在写入时自动格式化会很好.

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

我已经安装了 mssql 扩展.

I've already installed the mssql extension.

创建新文件时,文件是一个简单的纯文本,没有扩展名Untitled-1".

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

我到底如何告诉 VS Code 这是一个 SQL 脚本,以便正确格式化?

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

如果我按下 Shift+ALT+F,我只会收到错误没有安装‘纯文本’的格式化程序."

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

如果我使用扩展名.sql"保存文件,则应用该格式.

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.

在 VS Code 中,除了将文件另存为 SQL 文件之外,还有什么方法可以告诉编辑器该文件应该是 SQL 格式的吗?

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?

谢谢!

推荐答案

希望对你有所帮助.

如果我理解正确,您可以先使用这个快捷方式:

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".

还可以尝试访问此链接以获取更多信息:https://marketplace.visualstudio.com/items?itemName=cymonk.sql-formatter

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

您也可以访问此链接:https://code.visualstudio.com/docs/languages/overview您可以在其中找到更多相关信息,例如:

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

更改所选文件的语言

在 VS Code 中,我们默认基于文件扩展名的文件的语言支持.然而,有时您可能希望更改语言模式,为此单击语言指示器 - 位于右侧状态栏.这将打开选择语言模式下拉菜单您可以在其中为当前文件选择另一种语言.

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.

提示:您可以通过运行更改语言来获得相同的下拉菜单模式命令(Ctrl+K M).

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

这篇关于Visual Studio Code 与 SQL 格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆