在Visual Studio中,Windows上的Ctrl + K + F和Ctrl + K + D用于格式化,或在Visual Studio代码编辑器中“美化”代码的等效功能是什么?
当前回答
菜单文件→首选项→设置
"editor.formatOnType": true
当您输入分号时,它将被格式化。
或者,您也可以使用“editor”。formatOnSave”:真的。
其他回答
在Visual Studio Code中,Shift+Alt+F的作用就像在Visual Studio中Ctrl+K+D的作用一样。
您可以在菜单文件→首选项→键盘快捷键中添加按键绑定。
{ "key": "cmd+k cmd+d", "command": "editor.action.formatDocument" }
或者像Visual Studio那样:
{ "key": "ctrl+k ctrl+d", "command": "editor.action.formatDocument" }
在Visual Studio中格式化代码。
我尝试在Windows 8中格式化。
照着下面的截图就可以了。
单击顶部菜单栏上的“视图”,然后单击“命令面板”。 然后一个文本框将出现在我们需要键入格式 Shift + Alt + F
对于Fedora
单击文件->首选项->键盘快捷方式。 在默认键盘快捷键下,搜索(Ctrl + F) editor.action.format。
我的是“键”:“ctrl+shift+i”
你也可以改变它。参考这个关于如何……的答案。或者如果你觉得有点懒,就向上滚动:
您可以在“首选项->键盘快捷键”中添加一个键绑定 {“关键”:“cmd + k cmd + d”,“命令”:“editor.action。格式”} 或者像Visual Studio那样: {"key": "ctrl+k ctrl+d", "command": "editor.action. "格式”}
请注意:cmd键仅适用于mac电脑。对于Windows和Fedora (Windows键盘)使用Ctrl
编辑:
根据Visual Code版本1.28.2,这是我发现的。
Editor.action.format不再存在。它现在已经被editor.action.formatDocument和editor.action.formatSelection所取代。
在搜索框中输入editor.action.format查看现有的快捷方式。
按以下步骤更改键组合:
单击editor.action.formatDocument或editor.action.formatSelection 一个笔一样的图标出现左键点击它。 弹出窗口出现。按所需的组合键并按enter。
Shift + Alt + F在1.17.2和更高版本中可以很好地完成这项工作。
推荐文章
- 打开同一目录两次
- 如何从终端/命令行调用VS代码编辑器
- 如何在Visual Studio代码中重置设置?
- 如何将制表符转换为空格,反之亦然,在现有的文件
- 错误:'types'只能在.ts文件中使用- Visual Studio Code使用@ts-check
- Visual Studio Code: .git文件夹/文件隐藏
- c++中不必要的花括号
- Visual Studio Code:如何调试Python脚本的参数
- 如何在Visual Studio代码中触发参数提示?
- 在notepad++中格式化代码
- 在VS Code中禁用“Comments are not allowed In JSON”错误
- 使用正则表达式搜索和替换Visual Studio代码
- 如何缩进/格式选择的代码在Visual Studio代码?
- 如何禁用预览文件与点击在vs代码?
- 在Python中格式化多行字典的正确方法是什么?