visual-studio-codeterminal

How to restart the terminal in VS Code


I want to reset the terminal(any used) in Visual Studio Code with a hotkey. I don't see any option in the docs.


Solution

  • There is no single hotkey or command to reset the terminal.

    However, a possible solution is to combine different commands "to close the current terminal, open a new one, and focus it".

    To achieve this with a single hotkey:

    1- Install the Multi Command extension https://marketplace.visualstudio.com/items?itemName=ryuta46.multi-command

    2- Open settings.json by: open the command palette Ctrl+Shift+P and type Preferences: Open User Settings (JSON). This will allow you to configure the Multi Command extension. Add the following configuration to your settings.json file:

    "multiCommand.commands": [
        {
            "command": "multiCommand.newTerminalAndKillPrevious",
            "sequence": [
                "workbench.action.terminal.kill",
                "workbench.action.terminal.new",
                "workbench.action.terminal.focus"
            ]
        }
    ]
    

    3- Open your keybindings.json by going to the command palette Ctrl+Shift+P and typing Preferences: Open Keyboard Shortcuts (JSON).

    Add the following configuration to map the command to Ctrl+Shift+End (or any key combination you prefer):

    {
        "key": "ctrl+shift+end",
        "command": "extension.multiCommand.execute",
        "args": {
            "command": "multiCommand.newTerminalAndKillPrevious"
        }
    }
    

    4- Close the setting and press they hotkey you just set to reset the terminal ctrl+shift+end

    Note: If ctrl+shift+end is not working for you especially on Mac, try setting a different hotkey combination