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

时间:2018-02-26 02:06:10

标签: terminal visual-studio-code zsh

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

4 个答案:

答案 0 :(得分:2)

我没有zsh,但您可能会对cursorHome and cursorEnd命令或workbench.action.terminal.moveToLineStartworkbench.action.terminal.moveToLineEnd命令感到满意。两者都可以在命令选项板中的键盘快捷键或keybindings.json中设置 - ctrl+shift+p然后搜索键盘快捷键'

答案 1 :(得分:2)

正如在上面的评论中提到的:

打开 ~/.zshrc,并在末尾添加这一行:

bindkey -e

我不清楚为什么这会在 iTerm 中自动用于 zsh,但必须手动设置为在 VSCode 中与 zsh 一起使用。

答案 2 :(得分:1)

尝试这些键绑定:

  {
    "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+e to terminal
    "when": "terminalFocus"
  },

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

答案 3 :(得分:0)

尝试使用code从iTerm2启动Visual Studio代码。

那对我来说是成功的... cmd + cmd + 可以正常工作

尽管很奇怪...在GitHub上提出了一个问题。

相关问题