visual-studio-code - vscodevim中是否有进入插入模式/普通模式或其他模式的命令?
问题描述
我正在尝试在 VSCode 中创建一个非常简单的代码段,并且我正在使用 vim 扩展。插入代码段后,我成功进入了 insertMode。之后我什么都写不出来了。
这是我的python.json
文件:
"Print": {
"prefix": "print",
"body": [
"print($1)$0"
],
"description": "Print statement"
}
这是我的 settings.json:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "i", "p"],
"commands": [
{
"command": "editor.action.insertSnippet",
"args": {
"langId": "python",
"name": "Print"
}
},
{
"command": // COMMAND to enter insert mode here
},
{
"command": // COMMAND to type something (eg: `type` but I'm not sure I can use it with vim)
},
{
"command": // COMMAND to quit insert mode here
}
],
}
],
我知道我可以为片段写参数,但更多的是为了学习如何使用 vim 扩展,因为我想创建另一个使用 vim 的扩展。
这是我第一个问题的结尾,但我还有第二个问题:
当我使用这个键绑定时,我希望代码缩进。例如(“|”代表光标位置):
def my_function():
a = "super string"
|
应用快捷方式
这就是我要的:
def my_function():
a = "super string"
print(|)
这就是我得到的:
def my_function():
a = "super string"
print(|)
解决方案
Q1:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "i", "p"],
"commands": [
{
"command": "editor.action.insertSnippet",
"args": {
"langId": "python",
"name": "Print"
}
},
],
"after": ["i","t","y","p","e","<ESC>"]
}
],
还有一个命令extension.vim_insert
可能有用。像这样输入单词"t","y","p","e"
可能是不好的做法,只需制作自定义 vscode 片段即可。
Q2:
正确的方法是保持光标打开line 2
并按下o
键,自动缩进到您想要的位置。您很少会处于光标位于line 3
.
光标可能会出现的地方。
def my_function():
|a = "|super |string"|
之后o
。
def my_function():
a = "super string"
|
推荐阅读
- javascript - Laravel Stripe 和 Cashier 没有这种支付方式
- c++ - Threadpool 使用 C 代码,但无法在 C++ 项目中构建
- javascript - Webpack 调试工具
- flutter - 为什么我的扩展容器没有占据我设备的剩余高度?
- mongodb - 将聚合管道与更新运算符相结合
- javascript - 为什么 mapStateToDispatch 没有发送正确的值
- laravel - Laravel 向推送者广播消息
- javascript - 在数据表中启用编辑/删除
- r - 使用函数用 sd 估算异常值
- java - 当应用程序未在 Android 设备中运行时,如何在特定时间发送通知?