Visual Studio代码快捷键从当前或封闭代码块中出现

发布于 2025-01-24 23:40:56 字数 708 浏览 1 评论 0原文

Visual Studio代码中是否有任何快捷方式可以从当前代码块中出现。例如 -

while (!q.isEmpty()) {
    Oranges obj = q.pollFirst();
    ans = Math.max(obj.time, ans);
    for (int[] d : neighbors) {
        int r = obj.x + d[0];
        int c = obj.y + d[1];
        int t = obj.time + 1;//Cursor position
        if (r >= 0 && r < grid.length && c >= 0 && c < grid[0].length && grid[r][c] == 1) {
            q.offer(new Oranges(r, c, t));
            grid[r][c] = 2;
        }
    }//Target Position
}

在上面的代码中,假设我的光标位于光标位置,我想直接从当前代码块中出来或将循环置于 目标位置。 如果有任何可以做到的扩展名,请建议。

Is there any shortcut in visual studio code to come out of the current block of code. For example -

while (!q.isEmpty()) {
    Oranges obj = q.pollFirst();
    ans = Math.max(obj.time, ans);
    for (int[] d : neighbors) {
        int r = obj.x + d[0];
        int c = obj.y + d[1];
        int t = obj.time + 1;//Cursor position
        if (r >= 0 && r < grid.length && c >= 0 && c < grid[0].length && grid[r][c] == 1) {
            q.offer(new Oranges(r, c, t));
            grid[r][c] = 2;
        }
    }//Target Position
}

In code above, suppose my cursor is at Cursor position and I want to come directly out of the current block of code or enclosing for-loop to Target Position.
If there is any extension that can do it then please suggest.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

财迷小姐 2025-01-31 23:40:56

有一个键盘快捷键,称为“转到括号”(editor.action.jumptobracket),可让您接近所需的内容。其默认键为 ctrl + shift + \

从您拥有//光标位置的位置,它将跳到带有//目标位置的支架内部。因此:

while (!q.isEmpty()) {
    Oranges obj = q.pollFirst();
    ans = Math.max(obj.time, ans);
    for (int[] d : neighbors) {
        int r = obj.x + d[0];
        int c = obj.y + d[1];
        int t = obj.time + 1;//Cursor position
        if (r >= 0 && r < grid.length && c >= 0 && c < grid[0].length && grid[r][c] == 1) {
            q.offer(new Oranges(r, c, t));
            grid[r][c] = 2;
        }
    <cursor will move here>}//Target Position
}

如果您使用箭头键很快,则一旦将其放下,就可以通过此操作很快地绕过代码。

There is a keyboard shortcut called "Go to Bracket" (editor.action.jumpToBracket) that gets you close to what you want. Its default keys are Ctrl + Shift + \.

From where you have //Cursor position, it will jump down to the inside of the brace where you have //Target Position. So:

while (!q.isEmpty()) {
    Oranges obj = q.pollFirst();
    ans = Math.max(obj.time, ans);
    for (int[] d : neighbors) {
        int r = obj.x + d[0];
        int c = obj.y + d[1];
        int t = obj.time + 1;//Cursor position
        if (r >= 0 && r < grid.length && c >= 0 && c < grid[0].length && grid[r][c] == 1) {
            q.offer(new Oranges(r, c, t));
            grid[r][c] = 2;
        }
    <cursor will move here>}//Target Position
}

If you are quick with your arrow keys, you could navigate around your code quite fast with this once you get it down.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文