In your .zshrc or .bashrc file, add the following:

1
bindkey -e

In VSCode’s “Preferences: Open Keyboard Shortcuts.” (keybindings.json) add the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
    "key": "ctrl+u",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": " \u0015" },  // clear current line in terminal, sends ctrl+u to terminal
    "when": "terminalFocus"
},
{
    "key": "cmd+backspace",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": " \u0015" },  // clear current line in terminal, sends ctrl+u 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"
},
{
    "key": "cmd+left",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "\u0001" },  // move cursor to start of line, sends ctrl+a to terminal
    "when": "terminalFocus"
},
{
    "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": "cmd+right",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "\u0005" }, // move cursor to end of line, sends ctrl+e to terminal
    "when": "terminalFocus"
}

Reference

https://code.visualstudio.com/docs/terminal/advanced https://stackoverflow.com/questions/48980499/how-do-i-move-the-cursor-to-the-beginning-of-the-line-in-vscodes-terminal