Define keymappings for multiple modes at once in Vim or Neovim.
Put codes in your configuration file, such as .vimrc or init.vim.
" define mappings at once
Keymap nx S <Cmd>DoSomething<CR>
" same as ↓
" nnoremap S <Cmd>DoSomething<CR>
" xnoremap S <Cmd>DoSomething<CR>
" call 'map' instead of 'noremap' when '<Plug>' is detected
Keymap nx s <Plug>(do-something)
" same as ↓
" nmap s <Plug>(do-something)
" xmap s <Plug>(do-something)
" show existing mappings
Keymap nx
" same as ↓
" nmap
" xmap
" show existing mappings about specific key
Keymap nx s
" same as ↓
" nmap s
" xmap s
Neovim already has nvim_set_keymap()
and vim.keymap.set()
, but I wanted more simple command.