Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
clearissimple opened this issue Nov 14, 2019 · 5 comments
Open

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

clearissimple opened this issue Nov 14, 2019 · 5 comments

Comments

@clearissimple
Copy link

clearissimple commented Nov 14, 2019

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
Copy link
Owner

rickhowe commented Dec 1, 2019

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
Copy link
Author

clearissimple commented Dec 2, 2019

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
Copy link
Owner

rickhowe commented Dec 3, 2019

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
Copy link

mckellygit commented Mar 11, 2021

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
Copy link
Owner

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants