Set Neovim mode in VSCode
Mapping meta key for VSCode and Neovim
- Unification of meta key mapping between VSCode and Neovim
- Send meta key mapping from VSCode to Neovim
- Example of meta key for moving text
- VSCode Meta Key(<M-h/j/k/l>) --> Neovim Meta Key(<M-h/j/k/l>)
VSCode: keybinding.json(Shift-Cmd-P)
{
"command": "vscode-neovim.send",
// the key sequence to activate the binding
"key": "M+k",
// don't activate during insert mode
"when": "editorTextFocus && neovim.mode != insert",
// the input to send to neovim
"args": "<M-k>"
},
{
"command": "vscode-neovim.send",
// the key sequence to activate the binding
"key": "M+j",
// don't activate during insert mode
"when": "editorTextFocus && neovim.mode != insert",
// the input to send to neovim
"args": "<M-j>"
},
..
init.vim
" Normal Mode
nnoremap <M-K> <CMD>m .-2<CR>
nnoremap <M-J> <CMD>m .+1<CR>
nnoremap <M-H> <<
nnoremap <M-L> >>
" Visual Mode
vnoremap <M-K> :m '<-2<CR>gv
vnoremap <M-J> :m '>+1<CR>gv
vnoremap <M-H> <gv
vnoremap <M-L> >gv
Terminal emulator for meta key
- To send the meta key, you need to set the meta key in the terminal emulator.
- Mac: Terminal --> Preference --> Profile --> Key Board --> Enable "Use Option as Meta key"
- Emulator using xterm.js.
ttyd(macOptionIsMeta=true)/hyper(altIsMeta: true) Find and set the corresponding Option
Top comments (0)