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 拡張機能の操作方法を学習するためのものです。
これで最初の質問は終わりですが、2 番目の質問があります。
このキーバインディングを使用するときは、コードをインデントしたいと考えています。例 (「|」はカーソル位置を表します):
def my_function():
a = "super string"
|
ショートカットを適用しています
これは私が欲しいものです:
def my_function():
a = "super string"
print(|)
これは私が得るものです:
def my_function():
a = "super string"
print(|)