익명 14:42

Passing (forwarding) conflicting shortcut through VS Code to terminal (without a...

Passing (forwarding) conflicting shortcut through VS Code to terminal (without altering defaults)

Visual Studio Code integrates a terminal application. Terminals embedded that way can receive keyboard shortcuts, but these could be first caught by VS Code or its host (the local operating system). For example, the Ctrl+K combination has several uses:

  1. killing the remainder of the line in GNU Emacs
  2. killing the remainder of the line in GNU Bash
  3. cutting the line in GNU nano
  4. serving as a kind of prefix for Visual Studio Code chorded shortcuts.

Unfortunately, the first 3 can conflict with #4. Similarly, nano’s Ctrl+G is caught by VS Code.

These conflicts are treated in documentation, but:

Is there no way, which requires either no configuration or just setting 1 shortcut [prefix], to allow passing through all (or most) shortcuts to the terminal, without losing any shortcuts? For example, a shortcut indicating that the next combination should be passed, so that Ctrl+Alt+P, Ctrl+K would send a Ctrl+K interpreted by Bash/nano rather than being intercepted by Visual Studio Code for chorded shortcuts?

I guess this question is a proper version of How to send CTRL + v to terminal via terminal.sendSequence?. How to make Visual Studio Code forward caught keystrokes to shell? asks the same, but I will not accept answers which merely suggest workarounds involving tradeoffs between VS Code shortcuts and terminal shortcuts.

Workaround for text edition

When this affects edition with Emacs or GNU nano, a workaround is to edit using a VS Code editor instead. To edit foo.txt with the GUI:

code -r foo.txt

If this causes “Unable to connect to VS Code server: Error in request”, see the relevant bug report.



Top Answer/Comment:

This is addressed (to some extent) in the VS Code documentation: Keyboard shortcuts and the shell. Note that I have no experience with this other than knowing it exists.

The configurable terminal.integrated.commandsToSkipShell setting determines which command's keyboard shortcuts should always "skip the shell" and instead be handled by VS Code's keyboard shortcut system. By default, it contains a hard-coded list of commands that are integral to the VS Code experience but you can add or remove specific commands.

...

Tip: terminal.integrated.sendKeybindingsToShell can be configured to override terminal.integrated.commandsToSkipShell and dispatch most keyboard shortcuts to the shell. Note that this will disable keyboard shortcuts like Ctrl+F to open find though.

On a re-read of your question, though, I think you may already know about this, because it's not a "one option to control them all" kind of option, and is mentioned in a question you linked to... If this gets downvotes I'll delete it :)

상단 광고의 [X] 버튼을 누르면 내용이 보입니다