Cursor hijacks Cmd-K
, Cmd-Shift-K
, Cmd-L
for launching AI. Some of these are used to clear the terminal.
You can type clear
in the terminal, but that does not work if you have already typed in a command, and want to clear before it is run.
This is a workaround with a custom keyboard shortcut (I use Cmd-Alt-K
, on mac, you can change to anything you want that doesn't conflict with your existing workflows).
Note: you must be in the terminal to run this shortcut - you can switch to terminal using
Ctrl+backtick
(Yes, Ctrl, not Cmd on mac as well).
This tip is from cursor chat > claude 3.5 sonnet (updated for formatting and removed some platitudes)
-
Use VS Code’s Keybindings: Visual Studio Code lets you map custom key combinations to built-in commands. In this case, you can bind Cmd+Alt+K to a command that clears the terminal.
-
Select the Appropriate Command: VS Code already provides a built-in command for clearing the integrated terminal: "workbench.action.terminal.clear" This command immediately clears the terminal’s output (it does not send the text "clear" into the terminal, but it effectively clears it).
-
Modify Your Keybindings File: Open your keybindings JSON file (via the command palette, search for “Preferences: Open Keyboard Shortcuts (JSON)”) and add an entry mapping the key combination to the command. For example, you might add an entry similar to:
{
"key": "cmd+alt+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus"
}
This ensures that the shortcut takes effect when the terminal is active (the "when" clause is optional but recommended to avoid unintended conflicts).
Verify Conflict-Free Assignment: Make sure no other command is bound to Cmd+Alt+K. If there is, you may need to remove or change the conflicting binding.