Define keymappings for multiple modes at once in Vim or Neovim.
Put codes in your configuration file, such as .vimrc or init.vim.
:Keymap {modes} {arguments-of-map-commands}
" define mappings at once
Keymap nx s <Cmd>DoSomething<CR>
" same as ↓
" nnoremap s <Cmd>DoSomething<CR>
" xnoremap s <Cmd>DoSomething<CR>
" all options like '<expr>' are available
Keymap no <script> <expr> s SomeCondition() ? '<Plug>(do-something)' : 's'
" same as ↓
" nnoremap <script> <expr> s SomeCondition() ? '<Plug>(do-something)' : 's'
" onoremap <script> <expr> s SomeCondition() ? '<Plug>(do-something)' : 's'
" 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.