在vscodevim中是否有命令进入插入模式/普通模式或其他模式?

时间:2019-05-11 12:27:06

标签: 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(|)

1 个答案:

答案 0 :(得分:0)

第一季度:

"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"这样的单词可能是不好的做法,只需改成custom vscode snippets

第二季度:

正确的方法是将光标保持在line 2上并按下o键,自动缩进到您想要的位置。很少会把光标放在line 3的第一个字符上。

可能光标所在的地方。

def my_function():
    |a = "|super |string"|

o之后。

def my_function():
    a = "super string"
    |
相关问题