我正在尝试弄清楚如何在VSCodeVim中创建文本插入,例如:
inoremap <leader>sys <esc>ISystem.out.println(<esc>A);
vnoremap <leader>sys yOSystem.out.println(<esc>pA);
但我唯一能想到的就是一些黑客:
"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();" }
}
]
}
]
}