如何在Visual Studio代码(VSCode)中格式化代码

本文翻译自:How do you format code in Visual Studio Code (VSCode)

在Visual Studio中,Windows上的Ctrl + K + FCtrl + K + D等效于Visual Studio代码编辑器中的格式化或“美化”代码?


#1楼

参考:https://stackoom.com/question/21lRF/如何在Visual-Studio代码-VSCode-中格式化代码


#2楼

The code formatting is available in Visual Studio Code through the following shortcuts: Visual Studio Code中的代码格式通过以下快捷方式提供:

  • On Windows Shift + Alt + F 在Windows Shift + Alt + F上
  • On Mac Shift + Option + F 在Mac Shift + Option + F上
  • On Ubuntu Ctrl + Shift + I 在Ubuntu上按Ctrl + Shift + I.

Alternatively, you can find the shortcut, as well as other shortcuts, through the search functionality provided in the editor with Ctrl + Shift + P (or Command + Shift + P on Mac), and then searching for format document . 或者,您可以通过编辑器中使用Ctrl + Shift + P (或Mac上的Command + Shift + P )提供的搜索功能找到快捷方式以及其他快捷方式,然后搜索格式文档


#3楼

You can add a keybinding in menu FilePreferencesKeyboard shortcuts. 您可以在菜单文件首选项键盘快捷键中添加键绑定。

{ "key": "cmd+k cmd+d", "command": "editor.action.formatDocument" }

Or Visual Studio like: Visual Studio如:

{ "key": "ctrl+k ctrl+d", "command": "editor.action.formatDocument" }

#4楼

在Visual Studio代码中, Shift + Alt + F正在执行Ctrl + K + D在Visual Studio中执行的操作。


#5楼

右键组合为Shift + Alt + F.


#6楼

On Linux it is Ctrl + Shift + I . 在Linux上它是Ctrl + Shift + I.

On Windows it is Alt + Shift + F . 在Windows上,它是Alt + Shift + F. Tested with HTML/CSS/JavaScript and Visual Studio Code 1.18.0. 使用HTML / CSS / JavaScript和Visual Studio Code 1.18.0进行测试。

For other languages, you might need to install a specific language package. 对于其他语言,您可能需要安装特定的语言包。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值