zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
46.58k stars 2.64k forks source link

Add `editor::SendText` action for more flexible keybindings #4692

Open ubunatic opened 1 year ago

ubunatic commented 1 year ago

Check for existing issues

Describe the feature

I use a German keyboard with umlauts (ö,ä,ü) and like to remap them in the Editor and in the Terminal. It works in the Terminal.

Here is my working keymap.json:

[
  {
    "bindings": {
      "cmd-+": "zed::IncreaseBufferFontSize"
    }
  },
  {
    "context": "Terminal",
    "bindings": {
      "ö": [
        "terminal::SendText",
        "["
      ],
      "ä": [
        "terminal::SendText",
        "]"
      ],
      "Ö": [
        "terminal::SendText",
        "{"
      ],
      "Ä": [
        "terminal::SendText",
        "}"
      ],
      "alt-ö": [
        "terminal::SendText",
        "ö"
      ],
      "alt-ä": [
        "terminal::SendText",
        "ä"
      ],
      "alt-Ö": [
        "terminal::SendText",
        "Ö"
      ],
      "alt-Ä": [
        "terminal::SendText",
        "Ä"
      ]
    }
  }
]

I can already capture umlaut keypresses and trigger other actions in the Editor. This means the editor is already able to intercept regular key presses and not just with modifiers.

This works for instance:

    "bindings": {
      "ö": "workspace::Welcome"
    }

The Terminal already has a SendText action. Please also "enable" this in the Editor.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

nleroy917 commented 7 months ago

Hey, I'm going to hop on this; I think that I have a similar question(s).

  1. What must be done to apply the key bindings. Is a simple save of ~/.config/zed/keymap.json sufficient, or need I restart the application?
  2. I can't seem to get the terminal::SendText action to work. More below:

What I want to do: Send lines of code from the current file open down to be executed in the terminal. This is really nice when I am working on computing clusters in a REPL environment and editing files locally. I have this setup in VSCode:

{
  "key": "cmd+enter",
  "command": "workbench.action.terminal.runSelectedText",
  "when": "editorTextFocus"
}

Let me know how I might achieve this, and thank you!

fatherofinvention commented 6 months ago

I too am looking for a way to run the current line, or highlighted code, by sending it to the currently active terminal.

lud-wj commented 1 month ago

Hello,

I second this. The following config works only if the terminal is already in focus:

  {
    "context": "Workspace",
    "bindings": {
      "ctrl-alt-u": ["terminal::SendText", "my-command\n"]
    }
  }

It would be nice if it would work from anywhere.