VSCodeVim - 如何正确绑定文本插入?
VSCodeVim - How to bind text inserts properly?
我正在尝试弄清楚如何在 VSCodeVim 中创建文本插入,例如:
inoremap <leader>sys <esc>ISystem.out.println(<esc>A);
vnoremap <leader>sys yOSystem.out.println(<esc>pA);
但我唯一能想到的就是一些 hacky:
"vim.insertModeKeyBindingsNonRecursive": [
{
// Console.WriteLine
"before": ["<leader>", "c", "w", "l"],
"after": ["<Esc>","I","C","o","n","s","o","l","e",".","W","r","i","t","e","L","i","n","e","(","<Esc>","A",")",";"]
}
它确实运行良好。因为有这么多单独的键,延迟创建了一个非常令人愉快的动画 XD 问题是编写它们。我也为 For 循环写了一个,这不是一个好的体验。
必须有更好更简单的方法来做到这一点!如果我在某处的引号内有多个字符,它会停止序列。
谢谢!
您可以使用命令 editor.action.insertSnippet
。
{
"vim.insertModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "c", "w", "l"],
"commands": [
{
"command": "editor.action.insertSnippet",
"args": { "snippet": "Console.WriteLine();" }
}
]
}
]
}
我正在尝试弄清楚如何在 VSCodeVim 中创建文本插入,例如:
inoremap <leader>sys <esc>ISystem.out.println(<esc>A);
vnoremap <leader>sys yOSystem.out.println(<esc>pA);
但我唯一能想到的就是一些 hacky:
"vim.insertModeKeyBindingsNonRecursive": [
{
// Console.WriteLine
"before": ["<leader>", "c", "w", "l"],
"after": ["<Esc>","I","C","o","n","s","o","l","e",".","W","r","i","t","e","L","i","n","e","(","<Esc>","A",")",";"]
}
它确实运行良好。因为有这么多单独的键,延迟创建了一个非常令人愉快的动画 XD 问题是编写它们。我也为 For 循环写了一个,这不是一个好的体验。
必须有更好更简单的方法来做到这一点!如果我在某处的引号内有多个字符,它会停止序列。
谢谢!
您可以使用命令 editor.action.insertSnippet
。
{
"vim.insertModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "c", "w", "l"],
"commands": [
{
"command": "editor.action.insertSnippet",
"args": { "snippet": "Console.WriteLine();" }
}
]
}
]
}