DEV Community

EDICON
EDICON

Posted on • Edited on

2 1

Set Neovim and Using Meta key in VSCode

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>"
},
..
Enter fullscreen mode Exit fullscreen mode
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 
Enter fullscreen mode Exit fullscreen mode

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

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay