以下是一些常用的 VS Code 快捷键(Windows、macOS 和 Linux 均适用,略有不同):
常用快捷键
功能 | Windows/Linux | macOS |
---|---|---|
打开命令面板 | Ctrl + Shift + P 或 F1 | Cmd + Shift + P |
打开文件 | Ctrl + O | Cmd + O |
保存文件 | Ctrl + S | Cmd + S |
全部保存 | Ctrl + K, S | Cmd + Option + S |
关闭编辑器 | Ctrl + W | Cmd + W |
关闭所有编辑器 | Ctrl + K, W | Cmd + K, W |
新建文件 | Ctrl + N | Cmd + N |
代码导航
功能 | Windows/Linux | macOS |
---|---|---|
转到定义 | F12 | F12 |
查找所有引用 | Shift + F12 | Shift + F12 |
转到文件 | Ctrl + P | Cmd + P |
转到行 | Ctrl + G | Cmd + G |
转到符号 | Ctrl + Shift + O | Cmd + Shift + O |
多光标和选择
功能 | Windows/Linux | macOS |
---|---|---|
添加光标到下一行 | Ctrl + Alt + Down | Cmd + Option + Down |
添加光标到上一行 | Ctrl + Alt + Up | Cmd + Option + Up |
同时选中相同的单词 | Ctrl + D | Cmd + D |
取消多光标 | Esc | Esc |
编辑
功能 | Windows/Linux | macOS |
---|---|---|
复制行/块 | Shift + Alt + Down | Option + Shift + Down |
删除行 | Ctrl + Shift + K | Cmd + Shift + K |
移动行上/下 | Alt + Up/Down | Option + Up/Down |
格式化代码 | Shift + Alt + F | Shift + Option + F |
显示建议 | Ctrl + Space | Cmd + Space |
调试
功能 | Windows/Linux | macOS |
---|---|---|
开始/继续调试 | F5 | F5 |
单步进入 | F11 | F11 |
单步跳过 | F10 | F10 |
停止调试 | Shift + F5 | Shift + F5 |
终端操作
功能 | Windows/Linux | macOS |
---|---|---|
打开/关闭终端 | Ctrl + \ | `Cmd + `` |
新建终端 | `Ctrl + Shift + `` | `Cmd + Shift + `` |
切换终端 | Ctrl + Page Up/Down | Cmd + Page Up/Down |
常用技巧
-
快速打开最近使用的文件
Ctrl + R
(Windows/Linux)或Cmd + R
(macOS)
-
折叠/展开代码块
- 折叠:
Ctrl + Shift + [
或Cmd + Option + [
- 展开:
Ctrl + Shift + ]
或Cmd + Option + ]
- 折叠:
-
切换侧边栏可见性
Ctrl + B
(Windows/Linux)或Cmd + B
(macOS)
你也可以在 设置 -> 键盘快捷方式 中自定义这些快捷键!
设置vue模板
文件 - 首选项 - 用户片段 搜索vue.json文件,修改模板即可
快速生成模板:https://snippet-generator.app
vue.json 内容示例:
{"vue-template": {"prefix": "vue","body": ["<style lang=\"less\" scoped>","","</style>","","<template>"," <div>",""," </div>","</template>","","<script>","export default {"," mixins: [plugCx.IPlugBase],"," components: {},"," data()"," {"," return {",""," }"," },"," computed: {",""," },"," created()"," {",""," },"," mounted()"," {",""," },"," methods: {"," "," }","}","</script>","",""],"description": "vue-template"}
}