繁体   English   中英

用于跳出当前或封闭代码块的 Visual Studio Code 快捷方式

[英]Visual Studio Code shortcut to come out of the current or enclosing block of code

visual studio code 中是否有任何快捷方式可以退出当前代码块。 例如 -

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
}

在上面的代码中,假设我的 cursor 位于Cursor position并且我想直接跳出当前代码块或将 for 循环封闭到目标 Position 如果有任何扩展可以做到这一点,请提出建议。

有一个名为“Go to Bracket”( editor.action.jumpToBracket )的键盘快捷键,可以让您接近您想要的内容。 它的默认键是Ctrl + Shift + \

从你有//Cursor position的地方,它会跳到你有//Target Position的大括号内部。 所以:

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
}

如果您使用箭头键的速度很快,那么一旦按下它,您就可以使用它快速浏览您的代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM