Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move the cursor to the beginning of the line in VSCode's terminal?

I have my terminal set to zsh, and in iTerm2 I can press ctrl+e to move my cursor to the end of the line, and ctrl+a to move to the beginning. In VSCode, this just prints out a literal ^E^A. Is there a setting I need to allow terminal to respond to emacs style commands?

like image 947
Brian Schlenker Avatar asked Feb 26 '18 02:02

Brian Schlenker


2 Answers

Try these keybindings:

  {
    "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"
  },

Works in bash, I can't test in zsh but it should work.

like image 157
Mark Avatar answered Oct 21 '22 18:10

Mark


As was mentioned in a comment above:

Open ~/.zshrc, and add this line to the end:

bindkey -e

I'm unclear why this works automatically for zsh in iTerm, but must be manually set to work with zsh in VSCode.

like image 6
Adrian Macneil Avatar answered Oct 21 '22 17:10

Adrian Macneil