rickhowe / diffchar.vim

Highlight the exact differences, based on characters and words
http://www.vim.org/scripts/script.php?script_id=4932
MIT License
217 stars 10 forks source link

How to prevent the plugin from mapping <leader>g #21

Open clearissimple opened 4 years ago

clearissimple commented 4 years ago

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.

rickhowe commented 4 years ago

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

clearissimple commented 4 years ago

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.

rickhowe commented 4 years ago

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?

mckellygit commented 3 years ago

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

rickhowe commented 3 years ago

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>