vscode的使用技巧&快捷键摘要

常用的技巧和快捷键可以查看vscode官方给的快捷键图表
本文主要摘录一些快捷键图表上没有的内容


打开最近关闭的文件

win/linux ctr + shift + T
mac cmd +shift + T


调用层次

打开命令面板(ctr + shift + p
输入:Call Hierarchy 或者Peek Call Hierarchy
即可查看函数在哪些地方被调用


ctr + p

快速打开时,可以输入文件名中的字符、单词以及文件夹的名字,进行模糊搜索过滤
使用右键,可以不关闭悬浮窗,连续打开多个文件
使用ctr + rightArrow 可以在另一个编辑组中打开当前文件


终端组切换

使用ctr + `打开终端之后,可以使用ctr + PageUp/PageDown上下切换不同的bash/Debug…组

Terminal: Focus Next Terminal Group ctr + PageDown


1.hovering(悬停)

Inspect the value of the name variable by hovering over it in the editor while the execution is paused. You can view the value of variables at any time in the Variables view in the Run and Debug view.
在这里插入图片描述
调试时悬停直接查看变量的值:
在这里插入图片描述
在这里插入图片描述
如上,可以很方便的看到str2和str3指向的是同一个字符串常量(地址相同)


2. Side by side editing

You can open as many editors as you like side by side vertically and horizontally. If you already have an editor open, there are multiple ways of opening another editor to the side:

  • Alt and select a file in the Explorer view.
  • Ctrl+\ to split the active editor into two.
  • Open to the Side (Ctrl+Enter) from the Explorer context menu on a file.
  • Select the Split Editor button in the upper right of an editor.
  • Drag and drop a file to any side of the editor region. Hold Ctrl (Option on macOS) while dragging to copy the tab instead of moving it.
  • Press Ctrl+Enter in the Quick Open (Ctrl+P) file list.

3.Toggle Panel

Keyboard Shortcut: Ctrl+J
显示/隐藏终端

4.Navigate between recently opened folders and workspaces

Open a recent folder or workspace.

Keyboard Shortcut: Ctrl+R

在这里插入图片描述

5.Create or open a file from a link

Keyboard Shortcut: Ctrl+click (Cmd+click on macOS)

You can quickly open a file or image, or create a new file by moving the cursor to the file link and then pressing Ctrl+click.

在这里插入图片描述

6.Fast scrolling

Pressing the Alt key enables fast scrolling in the editor and Explorers. By default, fast scrolling uses a 5X speed multiplier but you can control the multiplier with the Editor: Fast Scroll Sensitivity (editor.fastScrollSensitivity) setting.

7.Copy line up / down

Keyboard Shortcut: Ctrl+Shift+Alt+Up or Ctrl+Shift+Alt+Down

The commands Copy Line Up/Down are unbound on Linux because the VS Code default keyboard shortcuts would conflict with Ubuntu keyboard shortcuts, see Issue #509. You can still set the commands editor.action.copyLinesUpAction and editor.action.copyLinesDownAction to your own preferred keyboard shortcuts.
在这里插入图片描述

8.Find In Selection

By default, the find operations are run on the entire file in the editor. It can also be run on selected text. You can turn this feature on by clicking the hamburger icon on the Find Widget.
默认为全局查找。局部查找,点击三条横线图即可在选择的范围内进行查找。
在这里插入图片描述
如下所示,用鼠标选择部分内容后,点击三条横线图标,可在选取的范围内进行局部查找。
在这里插入图片描述

9.Search across files

VS Code allows you to quickly search over all files in the currently opened folder. Press Ctrl+Shift+F and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location. Expand a file to see a preview of all of the hits within that file. Then single-click on one of the hits to view it in the editor.
就是放大镜图标的功能
在这里插入图片描述
1.编辑组中选中变量/函数/…/一段内容/甚至多段内容,使用快捷键 ctr +shift + F,就能在workspace中进行全局搜索
2.使用上下按键可以上下翻阅,使用左右按键,可以展开和折叠
3.使用ctr+ ←(左箭头),可以折叠所有内容
4.搜索栏的三个图标:区分大小写,单词匹配,使用正则表达式
5.三个点(...),可以展开,使用 include/exclude 文件/文件夹功能(名称正则表达式
6.shift + enter 换行 手动在搜索栏输入时,如果需要输入换行,但无法换行,使用 shift +enter
7.搜索栏使用上下键切换 到 历史搜索(内容)
8.在文件浏览(explorer)中,选中某个的文件夹/文件,右键显示菜单,选择Find in Foldershift + alt + f)即可快速跳转到对该文件夹/文件的全局搜索,从而避免输入一长串的文件路径

可以观看如下视频学习vscode的搜索功能:
vscode搜索功能

10.文件在编译组中的移动

在vscode中我要把namespace.cpp由第一个编辑组移动到第二个编辑组,怎么用快捷键实现?
在这里插入图片描述

  1. **先将光标移动到当前编辑器(已经默认) **

  2. 按下快捷键:
    Windows/Linux: Ctrl + K 然后松开,再按 RightArrow(→)
    macOS: Cmd + K 然后松开,再按 RightArrow(→)

这个组合是 VSCode 默认的“将编辑器移动到右侧编辑组”命令。


具体步骤:

  • 选中你想移动的文件的编辑器窗口(当前已激活)
  • 按下 Ctrl + K,松开后再按 (右箭头键)
  • 该文件就会被移动到右侧的第二个编辑组(如果没有则新建一个)
  • 向左移动则使用LeftArrow

上述内容有误

系统默认设置的ctr + k & L/R Arrow其实是移动整个编辑组,而不是单个文件在编辑组中的移动,单个文件在编辑组中的移动是ctr + alt + L/R Arrow

但是unbuntu24.04ctr + alt + L/R Arrow 是切换虚拟桌面!!!

linux下修改:
1.ctr + k & ctr + s进入快捷键设置
2.输入LeftArrow(RightArrow同理)
在这里插入图片描述

删除聚焦编辑组的快捷键

聚焦编辑组有另外的快捷键:ctr + num
eg. ctr + 1 : 聚焦到第一编辑组

在这里插入图片描述
View: Move Editor into Previous Group修改为ctr + k & ctr + LeftArrow
(回车或者直接点击,先按下ctr + k再按下ctr + LeftArrow,然后回车)
在这里插入图片描述
现在就可以使用ctr + k & ctr + LeftArrow将文件左移到上一个编辑组
右移也是同样的方法修改
以上系统自带的快捷键设置是在Linux下,如果win下不可行,使用ctr + k & ctr + s进入快捷键设置,输入LeftArrow/RightArrow自行查看在编辑组中移动文件的快捷键


11.编辑组中文件的 切换 移动

ctr + PageUp | PageDown,可以上下切换(聚焦)到相邻的文件
Ctr + shift + PageUp | PageDown 可以移动当前聚焦的文件(往左|右移动一位)


12.ctr + shift + ;

Focus Breadcrumbs

在这里插入图片描述
光标停在某个函数/对象/变量上,可以使用ctr +shift + ;,这样就能选中Breadcrumbs(文件第一行上面悬浮的小栏),再按enter键,就可以快速的弹出相关的内容:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值