VSCode のNeovimプラグインのInsertモードで、Emacs風のキーバインドを使用する

表題通り、VSCode にNeovimプラグインを導入した状態で、 Insertモード中にEmacs風のキーバインドを使いたいと思い、以下のような設定をinit.vimに記述しました。

"Emacsキーバインド
inoremap <silent> <C-a> <Home>
inoremap <silent> <C-e> <End>
inoremap <silent> <C-h> <BS>
inoremap <silent> <C-d> <Del>

けど、全然想定通りに動かない・・・

ちょっと調べたところ、こんな記事を発見した。

VSCodeの拡張機能のVSCode NeoVimについて

Insertモードのキーバインドは、init.vimに記述してもダメなのね。

VSCodeのkeybindings.jsonに以下の記述を追加して解決!

{
"key": "ctrl+a",
"command": "cursorHome",
"when": "neovim.mode == insert && editorTextFocus"
},
{
"key": "ctrl+e",
"command": "cursorEnd",
"when": "neovim.mode == insert && editorTextFocus"
},
{
"key": "ctrl+h",
"command": "deleteLeft",
"when": "neovim.mode == insert && editorTextFocus"
},
{
"key": "ctrl+d",
"command": "deleteRight",
"when": "neovim.mode == insert && editorTextFocus"
},
{
"key": "ctrl+k",
"command": "deleteAllRight",
"when": "neovim.mode == insert && editorTextFocus"
},
{
"key": "ctrl+m",
"command": "type",
"args": { "text": "\n" },
"when": "neovim.mode == insert && editorTextFocus"
}

自分が使いたいものだけ記述しましたが、以下のドキュメントを参考にすれば、他にも色々と設定できそうです。

https://github.com/vscode-neovim/vscode-neovim