Visual studio code 需要VSCode sendSequence keybindings用于上一个命令、下一个命令、移动到行首、移动到行尾终端命令 我当前的自定义键绑定
这些与1.45更新集成的终端更新配合良好 -但我需要更多的信息 我想使用“ijkl”键,如“wasd”游戏标准,如我的自定义项目 所以我的想法是 我们是否可以将序列发送到终端以显示上一个命令/下一个命令,就像我们单击向上/向下箭头时一样Visual studio code 需要VSCode sendSequence keybindings用于上一个命令、下一个命令、移动到行首、移动到行尾终端命令 我当前的自定义键绑定,visual-studio-code,terminal,Visual Studio Code,Terminal,这些与1.45更新集成的终端更新配合良好 -但我需要更多的信息 我想使用“ijkl”键,如“wasd”游戏标准,如我的自定义项目 所以我的想法是 我们是否可以将序列发送到终端以显示上一个命令/下一个命令,就像我们单击向上/向下箭头时一样 { "key": "alt+x", // or whatever you choose "command": "workbench.action.terminal.sendSequence", "args": { "
{
"key": "alt+x", // or whatever you choose
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b[A\n"
}
// 1 up arrow or previous command, works in cmd, git bash and powershell
// the \n at the end makes it execute the previous command immediately,
// leave it off if you don't want to do that
// \u000d, a carriage return, is equivalent to \n if you prefer to use that, so
// \u001b[A\u000d does the same thing as \u001b[A\n
> /** Carriage Return (Caret = ^M, C = \r) */
> export const CR = '\x0d';
{
"key": "alt+y", // or whatever you choose
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b[B\n"
}
// 1 down arrow
// see comment above about immediate command execution
moveToLineStart/moveToLineEnd序列已随此更新删除。rry我找不到或无法生成序列。我们可以通过sendSequence获得此效果吗
我们是否可以将序列发送到终端以显示上一个命令/下一个命令,就像我们单击向上/向下箭头时一样
{
"key": "alt+x", // or whatever you choose
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b[A\n"
}
// 1 up arrow or previous command, works in cmd, git bash and powershell
// the \n at the end makes it execute the previous command immediately,
// leave it off if you don't want to do that
// \u000d, a carriage return, is equivalent to \n if you prefer to use that, so
// \u001b[A\u000d does the same thing as \u001b[A\n
> /** Carriage Return (Caret = ^M, C = \r) */
> export const CR = '\x0d';
{
"key": "alt+y", // or whatever you choose
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b[B\n"
}
// 1 down arrow
// see comment above about immediate command execution
有关这些箭头命令,请参见
使用CSI的函数,按最终字符排序
CSI Ps A光标向上Ps乘以默认值=1 CUU
CSI Ps B光标向下Ps乘以默认值=1 CUD
此部分\u001b[是文档中提到的转义序列或CSI。使用A表示光标向上箭头so\u001b[A或使用B表示向下箭头so\u001b[B]表示转义序列
[从理论上讲,您应该能够立即执行\u001b[2A对于上面向上箭头所指的Ps部件,但对于我来说,这在vscode中似乎永远不起作用。]
我使用了常用的键绑定(至少在bash中)来转到命令行的开始或结束
从本文件
我们看到Ctrl+A是:
/**标题开头插入符号=^A*/[即Ctrl+A]
导出常量SOH='\x01'
因此,我使用了\u0001 unicode序列来替换列出的\x01,该序列不能与sendSequence命令一起使用
同样,要将Ctrl+E发送到终端,以便转到命令行的末尾,我们可以看到Ctrl+E是:
/**查询插入符号=^E*/[即Ctrl+E]
导出常量ENQ='\x05'
或unicode\u0005
现在,您的终端shell可能会在命令行的“转到开始/结束”中使用除Ctrl+A和Ctrl+E以外的其他内容。如果我的键绑定不适用于您,请找出shell在“转到开始/结束”中使用的内容,并查看它们是否在
{
"key": "ctrl+e",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u0005" }, // move cursor to end of line, bash at least
"when": "terminalFocus"
},
{
"key": "ctrl+a",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u0001" }, // move cursor to start of line, bash at least
"when": "terminalFocus"
},