簡體   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-2024 STACKOOM.COM