diffchar.vim icon indicating copy to clipboard operation
diffchar.vim copied to clipboard

How to prevent the plugin from mapping <leader>g

Open clearissimple opened this issue 5 years ago • 5 comments

You can use ]b or ]e to jump cursor to start or end position of the next difference unit, and [b or [e to the start or end position of the previous unit. Those keymaps are configurable in your vimrc and so on.

I can create additional keymaps, but how do I prevent the plugin from hijacking <leader>g for example.

clearissimple avatar Nov 14 '19 16:11 clearissimple

This plugin uses <Leader>g for <Plug>GetDiffCharPair as a default. If <Leader>g has been defined in your vimrc, this plugin does not overwrite your mapping, but <Plug>GetDiffCharPair will not work. If you still want to use it, try to set other key in your vimrc like this:

nmap <silent> <Leader>h <Plug>GetDiffCharPair

rickhowe avatar Dec 01 '19 08:12 rickhowe

I don't think it works that way. The reason I am asking is that I have <leader>g mapped in my vimrc and diffchar maps it nonetheless.

clearissimple avatar Dec 02 '19 10:12 clearissimple

For example, I tried to set this in my vimrc, nmap <Leader>g :echo localtime()<CR> diffchar does not overwrite the mapping and <Leader>g correctly echoes the local time. How do you exactly define <Leader>g in your vimrc?

rickhowe avatar Dec 03 '19 06:12 rickhowe

Hi, Thank you for this great plugin. This is what I did to unmap <Leader>p and <Leader>g since I use other p* and g* mappings -

" diffchar ---------
function s:UnmapSomeDiffCharKeys()
    try
        nunmap <Leader>p
        nunmap <Leader>g
    catch /E31:/
    endtry
endfunction
autocmd BufEnter * call <SID>UnmapSomeDiffCharKeys()
" diffchar ---------

You could add your own <Leader>p mapping in this function after the endtry. thx, -m

mckellygit avatar Mar 11 '21 13:03 mckellygit

The plugin does not overwrite the mappings, such as <Leader>g, if those are defined in your vimrc. Is there any case to overwrite your mappings? Please let me know.

By the way, you can disable those functionalities and mappings:

nmap <Nop>(g) <Plug>GetDiffCharPair
nmap <Nop>(p) <Plug>PutDiffCharPair

or

nmap <Leader>g <Nop>
nmap <Leader>p <Nop>

rickhowe avatar Mar 15 '21 05:03 rickhowe