Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use keybinds with init.vim file in VSCode-Neovim

I am setting Extension VSCode Neovim for Mac.

I added the following code to settings.json to use init.vim with my keybinds set.

I can use vim in vscode, but key bindings don't work.

Do I need other settings besides settings.json?


settings.json

"vscode-neovim.neovimExecutablePaths.darwin": "/usr/local/bin/nvim",
"vscode-neovim.neovimInitVimPaths.darwin": "/Users/myname/.config/nvim/init.vim"

init.vim

set shiftwidth=4
set tabstop=4
set expandtab
set textwidth=0
set autoindent
set hlsearch
set clipboard=unnamed
syntax on

noremap <C-a> ^
noremap <C-e> $
inoremap <silent> jj <ESC>
noremap <C-j> <esc>
noremap! <C-j> <esc>

VSCode Version: 1.62.3

VSCode Neovim: 0.0.82

NVIM v0.5.1

Mac BigSur 11.5.2

like image 821
Tio Avatar asked Nov 08 '25 01:11

Tio


1 Answers

VSCode-Neovim works differently than regular Neovim, specifically in insert mode is managed by VS Code using keybindings.json

For example if you need to map jj to <Esc> you can add this to your keybindings.json

{
    "command": "vscode-neovim.compositeEscape1",
    "key": "j",
    "when": "neovim.mode == insert && editorTextFocus",
    "args": "j"
}

Most of Ctrl keys are already mapped by the extensions.

like image 108
Andy Avatar answered Nov 09 '25 21:11

Andy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!