简体   繁体   中英

vim map confliction between vimrc and plugin

I'm using jedi-vim . It defines key map <Leader>n as some commands while I also defines it in .vimrc file like following.

nnoremap <Leader>n <C-w><C-w>

But when I typed <Leader>n in python file, jedi#usages() command was executed.

:map <Leader>n returns:

n  <Space>n    *@:call jedi#usages()<CR>
n  <Space>n    * <C-W><C-W>

I also tried to unmap <Leader>n before I defined the map. However, it raised an error saying nothing was defined.

How to avoid this conflict?

I know the problem will be fixed when I define g:jedi#usages_command to another command. I'd like to know the way to avoid overlapping mapping.

I know the problem will be fixed when I define g:jedi#usages_command to another command. I'd like to know the way to avoid overlapping mapping.

Defining g:jedi#usages_command is "the way to avoid overlapping mapping".

Plugin mappings always take precedence over yours because they define their mappings after you have defined yours.

There are solutions at the script level, like using <unique> , or checking if the mapping already exists, or simply not defining any user-level mapping… but that's the responsibility of the developer, not yours.

--- edit ---

To expand on Christian's comment… the last mapping always wins, that's how it works and nothing can be done by the user to protect his mappings.

Plugin developers, though, have a few mechanisms at their disposal for preventing their plugins to overwrite user mappings and user settings so it is not unreasonable to expect them to use those mechanisms to respect your mappings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM