Oliver
Oliver

Reputation: 441

How to use the same keymapping for two different (neo)vim plugins

I would like to map "Control-Space" for two plugins I am using for neovim:

Plug 'gaalcaras/ncm-R' (for r files)
Plug 'bfredl/nvim-ipy' (for python files)

In order to achieve this for normal mode, I have tried:

autocmd FileType r nmap <C-Space> <Plug>RDSendLine
autocmd FileType python nmap <C-Space> <Plug>(IPy-Run)

Howevver, the second mapping always overwirtes the first one (for all buffers, all file types). Obviously I cannot get this to work in a file type dependent way.

Upvotes: 0

Views: 421

Answers (1)

Matt
Matt

Reputation: 15081

You should use buffer-specific mappings:

autocmd FileType r nmap <buffer><C-Space> <Plug>(RDSendLine)
autocmd FileType python nmap <buffer><C-Space> <Plug>(IPy-Run)

Upvotes: 2

Related Questions