如何将光标移动到 VSCode 终端中的行首?

Bri*_*ker 13 terminal zsh visual-studio-code

我将终端设置为 zsh,在 iTerm2 中,我可以按ctrl+e将光标移动到行尾,然后ctrl+a移动到行首。在 VSCode 中,这只是打印出一个文字^E^A. 是否需要设置允许终端响应 emacs 样式命令?

Adr*_*eil 7

正如上面评论中提到的:

打开~/.zshrc,并将此行添加到末尾:

bindkey -e
Run Code Online (Sandbox Code Playgroud)

我不清楚为什么它在 iTerm 中自动适用于 zsh,但必须手动设置才能在 VSCode 中使用 zsh。


Mar*_*ark 6

尝试这些键绑定:

  {
    "key": "ctrl+e",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "\u0005" },   // move cursor to end of line, sends ctrl+e to terminal
    "when": "terminalFocus"
  },
  
  {
    "key": "ctrl+a",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "\u0001" },   // move cursor to start of line, sends ctrl+a to terminal
    "when": "terminalFocus"
  },
Run Code Online (Sandbox Code Playgroud)

在 bash 中工作,我无法在 zsh 中测试,但它应该可以工作。