VSCode + VSCodeVim 撤消键重新绑定
VSCode + VSCodeVim undo key rebinding
VSCodeVim 使用不同的撤消堆栈,当撤消 vim 撤消堆栈中所有未保存的更改后,VSCode 仍然显示文件未保存时,这让我很烦。出于这个原因,我想使用 VSCode 的撤消堆栈并将 "u" 映射到 "Ctrl+z"。
我的快捷键如下:
{
"key": "u",
"command": "undo",
"when": "editorTextFocus && !editorReadonly && vim.active && vim.mode != 'Insert'"
}
问题是,即使我指定它在 vim 模式为 Insert 时不工作,它仍然撤消最后的更改并插入 'u'。谁能建议重新绑定撤消的正确方法是什么?
我尝试了 Doktor OSwaldo 的建议,但由于某种原因它不起作用。
但是我设法找到了解决方案:
"vim.otherModesKeyBindingsNonRecursive": [
{
"before": ["u"],
"after": [],
"commands": [
{
"command": "undo",
"args": []
}
]
}
]
搭载 dtasev's
... the "args": []
doesn't seem to be necessary, and "otherModesKeyBindingsNonRecursive"
doesn't exist as an option anymore. I bound mine to normalModeKeyBindings
. Also bound <C-r>
to redo
to use VSCode's redo stack as well
在 上(并且要明确使用 JSON),这是我在 settings.json 中使用 vim.normalModeKeyBindingsNonRecursive
而不是 vim.normalModeKeyBindings
:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["u"],
"after": [],
"commands": [
{
"command": "undo",
"args": []
}
]
},
{
"before": ["<C-r>"],
"after": [],
"commands": [
{
"command": "redo",
"args": []
}
]
}
]
VSCodeVim 使用不同的撤消堆栈,当撤消 vim 撤消堆栈中所有未保存的更改后,VSCode 仍然显示文件未保存时,这让我很烦。出于这个原因,我想使用 VSCode 的撤消堆栈并将 "u" 映射到 "Ctrl+z"。 我的快捷键如下:
{ "key": "u", "command": "undo", "when": "editorTextFocus && !editorReadonly && vim.active && vim.mode != 'Insert'" }
问题是,即使我指定它在 vim 模式为 Insert 时不工作,它仍然撤消最后的更改并插入 'u'。谁能建议重新绑定撤消的正确方法是什么?
我尝试了 Doktor OSwaldo 的建议,但由于某种原因它不起作用。 但是我设法找到了解决方案:
"vim.otherModesKeyBindingsNonRecursive": [
{
"before": ["u"],
"after": [],
"commands": [
{
"command": "undo",
"args": []
}
]
}
]
搭载 dtasev's
... the
"args": []
doesn't seem to be necessary, and"otherModesKeyBindingsNonRecursive"
doesn't exist as an option anymore. I bound mine tonormalModeKeyBindings
. Also bound<C-r>
toredo
to use VSCode's redo stack as well
在 vim.normalModeKeyBindingsNonRecursive
而不是 vim.normalModeKeyBindings
:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["u"],
"after": [],
"commands": [
{
"command": "undo",
"args": []
}
]
},
{
"before": ["<C-r>"],
"after": [],
"commands": [
{
"command": "redo",
"args": []
}
]
}
]