vscode快捷键,你都知道那些

134 阅读8分钟

做事情追求快,那么快捷键和称手好用的工具必不可少。

快捷键

win

wind+上下左右箭头 窗口最大化、最小化、靠左、靠右排布

wind+tab切换不同应用

如何切换同应用的不同窗口?

安装Easy Window Switcher软件,就可以像mac一样alt+~一样使用了

win+l锁屏 win+d显示桌面, win+e显示资源管理器

alt+esc 隐藏当前窗口 alt+f4 退出当前窗口

win+l 类似于浏览器,鼠标focus到地址栏 在地址栏中输入cmd,可以直接在当前目录打开cmd,不用再cd一堆路径了

delete 选中文件、文件夹后 可删除(移动到回收站)

shift+delete 选中文件、文件夹后 可直接彻底删除

vscode的快捷键

General - 通用

Ctrl+Shift+P或F1 Show Command Palette 打开命令面板 ;

Ctrl+P Quick Open, Go to File… 通过搜索窗口快速打开文件;

Ctrl+Shift+N New window/instance 打开一个新窗口或实例;

Ctrl+Shift+W Close window/instance 关闭新窗口或实例;

Ctrl+,  User Settings 注意这里是ctrl加逗号,进入用户设置;

Ctrl+K Ctrl+S Keyboard Shortcuts 这里是按crtl后,再按k,然后按s就会弹出快捷键窗口;


Basic editing - 基本的编辑快捷键

Ctrl+X Cut line (empty selection) 剪切行;

Ctrl+C Copy line (empty selection) 拷贝行;

Alt+ ↑ / ↓ Move line up/down 按住alt,按向上的箭头该行就向上移动,按向下的箭头该行就向下移动;

Shift+Alt + ↓ / ↑ Copy line up/down 这个是拷贝行,向上箭头拷贝到上面,向下拷贝就到下面;

Ctrl+Shift+K Delete line 删除行;

Ctrl+Enter Insert line below 把光标移动到所在行的下面进行插入操作;

Ctrl+Shift+Enter Insert line above 把光标移动到所在行的上面进行插入操作;

*Ctrl+Shift+* Jump to matching bracket 跳转到匹配的括号,括号多了难免混淆,用这个来检查;

Ctrl+] / [ Indent/outdent line 在行内左右缩进;

Home / End Go to beginning/end of line 光标所在行的行首(home键),行尾(end键);

Ctrl+Home Go to beginning of file 把光标移动到文件头部;

Ctrl+End Go to end of file 把光标移动到文件尾部;

Ctrl+↑ / ↓ Scroll line up/down 按照行向上滚动或按照行向下移动;

Alt+PgUp / PgDn Scroll page up/down 按照页向上滚动或按照页向下移动;

Ctrl+Shift+[ Fold (collapse) region 区域折叠

Ctrl+Shift+] Unfold (uncollapse) region 打开折叠的区域

Ctrl+K Ctrl+[ Fold (collapse) all subregions 折叠全部子区域

Ctrl+K Ctrl+] Unfold (uncollapse) all subregions 打开全部子区域

Ctrl+K Ctrl+0 Fold (collapse) all regions 折叠全部区域

Ctrl+K Ctrl+J Unfold (uncollapse) all regions 打开全部折叠区域

Ctrl+K Ctrl+C Add line comment 添加行注释

Ctrl+K Ctrl+U Remove line comment 删除行注释

Ctrl+/  Toggle line comment 把改行注释

Shift+Alt+A Toggle block comment 把选定的块注释掉;

Alt+Z Toggle word wrap 切换到自动换行,当你的行很长,不换行就用这个快捷键;


Navigation - 导航

Ctrl+T Show all Symbols 显示所有符号;

Ctrl+G Go to Line... 弹出导航栏,输入你要去的行号回车;

Ctrl+P Go to File... 查找文件;

Ctrl+Shift+O Go to Symbol... 查找变量,函数等符号,把光标移动到指定位置;

Ctrl+Shift+M Show Problems panel 显示问题面板;

F8 Go to next error or warning 转到下一个错误或警告,我的笔记本按这个键与其他程序有冲突;

Shift+F8 Go to previous error or warning 转到上一个错误或警告;

Ctrl+Shift+Tab Navigate editor group history 在你打开的文件窗口里切换;

Alt+ ← / → Go back / forward 向前向后移动到你编辑的历史位置;

Ctrl+M Toggle Tab moves focus 切换光标移动的范围,把光标切换到编辑窗口外面,按住tab键切换;


Search and replace - 搜索和替换

Ctrl+F Find 查找;

Ctrl+H Replace 替换;

F3 / Shift+F3 Find next/previous F3查找下一个,shift加F3查找上一个,我的笔记本这两个开关是调音量的;

Alt+Enter Select all occurences of Find match 查找到的匹配的字符全选;

Ctrl+D Add selection to next Find match 将选择添加到下一个查找匹配项;

Ctrl+K Ctrl+D Move last selection to next Find match 将上一个选择移动到下一个查找匹配项;

Alt+C / R / W Toggle case-sensitive / regex / whole word 通过alt+c区分大小写,alt+r使用正则表达式,alt+w使用选中的单词;


Multi-cursor and selection - 多光标和选择

Alt+Click Insert cursor alt+左键鼠标点击,可以添加多个光标;

Ctrl+Alt+ ↑ / ↓ Insert cursor above / below 上下移动光标形成一列光标,在这一列光标前插入字符;

Ctrl+U Undo last cursor operation 撤消上次光标操作,使用ctrl+u没有反应,ctrl+z能用,错否?

Shift+Alt+I Insert cursor at end of each line selected 在选定的每一行的末尾插入光标;

Ctrl+L Select current line 向下选择多行;

Ctrl+Shift+L Select all occurrences of current selection 选择多个相同字符;

Ctrl+F2 Select all occurrences of current word 我的这个快捷键不能用,选择多个相同的单词;

Shift+Alt+→ Expand selection 扩大选择;

Shift+Alt+← Shrink selection 缩小选择;

Shift+Alt +(drag mouse)  Column (box) selection 按住shift和alt按住鼠标左键拖动鼠标选择块;

Ctrl+Shift+Alt+ (arrow key)  Column (box) selection 按住shift+alt+ctrl三个键,通过箭头键选择块;

Ctrl+Shift+Alt+PgUp/PgDn Column (box) selection page up/down 同上,这个方法选择更快;


Rich languages editing - 多语言编辑

Ctrl+Space, Ctrl+I Trigger suggestion 触发器建议;

Ctrl+Shift+Space Trigger parameter hints 触发器参数提示;

Shift+Alt+F Format document 格式化文档;

Ctrl+K Ctrl+F Format selection 格式化选定区域;

F12 Go to Definition 转到定义;

Alt+F12 Peek Definition 查看定义;

Ctrl+K F12 Open Definition to the side 打开定义到边;

Ctrl+.  Quick Fix 快速修复;

Shift+F12 Show References 显示引用;

F2 Rename Symbol 重命名符号;

Ctrl+K Ctrl+X Trim trailing whitespace 修剪尾随空格;

Ctrl+K M Change file language 改变编辑的语言;


Editor management - 编辑器管理

Ctrl+F4, Ctrl+W Close editor 关闭编辑器;

Ctrl+K F Close folder 关闭文件夹;

*Ctrl+* Split editor 拆分编辑器;

Ctrl+ 1 / 2 / 3 Focus into 1 st, 2nd or 3rd editor group 放到第 1组或第 2 组或第 3 编辑组,这个不会用;

Ctrl+K Ctrl+ ←/→ Focus into previous/next editor group 放到先前或下一个编辑组;

Ctrl+Shift+PgUp / PgDn Move editor left/right 移动编辑器到左或右;

Ctrl+K ← / → Move active editor group 移动激活编辑器到组;


File management - 文件管理

Ctrl+N New File 打开一个新文件;

Ctrl+O Open File... 打开文件;

Ctrl+S Save 保存文件;

Ctrl+Shift+S Save As.. 保存文件到指定路径.;

Ctrl+K S Save All 保存全部打开的文件;

Ctrl+F4 Close 关闭文件;

Ctrl+K Ctrl+W Close All 关闭vscode打开的所有文件;

Ctrl+Shift+T Reopen closed editor 重新打开关闭的编辑器;

Ctrl+K Enter Keep preview mode editor open 输入保持预览模式编辑器打开;

Ctrl+Tab Open next 打开下一个;

Ctrl+Shift+Tab Open previous 打开先前的文件;

Ctrl+K P Copy path of active file 拷贝当前激活的文件路径;

Ctrl+K R Reveal active file in Explorer 在资源管理器中显示当前打开文件的位置;

Ctrl+K O Show active file in new window/instance 在新窗口中打开当前激活的文件;


Display - 显示

F11 Toggle full screen 切换到全屏;

Shift+Alt+0 Toggle editor layout (horizontal/vertical) 切换编辑器布局(水平/垂直);

Ctrl+ = / - Zoom in/out 放大或缩小vscode窗口大小;

Ctrl+B Toggle Sidebar visibility 切换侧边栏是否可见;

Ctrl+Shift+E Show Explorer / Toggle focus 显示浏览器窗口或切换焦点

Ctrl+Shift+F Show Search 显示搜索;

Ctrl+Shift+G Show Source Control 显示源码控制窗口;

Ctrl+Shift+D Show Debug 显示debug窗口;

Ctrl+Shift+X Show Extensions 显示插件窗口;

Ctrl+Shift+H Replace in files 替换文件;

Ctrl+Shift+J Toggle Search details 切换搜索详情;

Ctrl+Shift+U Show Output panel 显示输出板;

Ctrl+Shift+V Open Markdown preview 打开一个markdown预览;

Ctrl+K V Open Markdown preview to the side 再边上打开一个markdown预览;

Ctrl+K Z Zen Mode (Esc Esc to exit) zen模式,zen又称禅模式,就是专注编写代码,按两次esc推出;


Debug - 调试

F9 Toggle breakpoint 切换断点,我的电脑f1-f9都不能用,需要的自定义这些快捷键;

F5 Start/Continue 开始、继续

Shift+F5 Stop 停止

F11 / Shift+F11 Step into/out 单步跳入、跳出

F10 Step over 单步跳过

Ctrl+K Ctrl+I Show hover 显示悬停,用来复制悬停里的内容用;


Integrated terminal

Ctrl+`  Show integrated terminal 显示终端窗口,再按一次关闭;

Ctrl+Shift+`  Create new terminal 创建一个新的终端窗口;

Ctrl+C Copy selection 拷贝;

Ctrl+V Paste into active terminal 粘贴到激活的终端;

Ctrl+↑ / ↓ Scroll up/down 向上向下滚动;

Shift+PgUp / PgDn Scroll page up/down 向上向下页滚动,更快;

Ctrl+Home / End Scroll to top/bottom 直接到顶,直接到底部;