user1050817
user1050817

Reputation: 963

How change shortcut for plugins in Vim

I'm trying remap the shortcut for run easymotion in vim for the same key than I use in Emacs: shift + Enter

 nnoremap <S-Enter> :call easymotion-prefix() <CR>

running this vim show a warning alert than I'm missing some parenthesis, I try (easymotion-prefix) too..but this doesn't works neither

I wrote it inside my .vimrc, I don't know if I can do this or I need write directly inside the plugin, do I need remove the previous keymap? or change the original file easymotion , thanks!.....

Upvotes: 0

Views: 1170

Answers (1)

Brady Trainor
Brady Trainor

Reputation: 2076

I did some digging, and this worked

map <S-Enter> <Plug>(easymotion-prefix)

Places to find this:

README.md

The easiest way to find it may have been to visit the plugin's Github page, as here we can enjoy the browser's parsing of the markdown and source. That page opens to the bundle's README.md, which you can also read in your ~/.vim/bundle/vim-easymotion/ directory from the comfort of Vim.

:help

Other sensible places to solve your problem, would have been the :help easymotion.txt, or if you don't have help files for your plugins properly aligned, you can simply visit vim-easymotion/easymotion.txt. You can bounce around in there as some other sections will point you closer, but easymotion-custom-mappings is the relevant section.

plugin/

And if all else fails, you can check out the plugin directory, in this case we can inspect the vim-easymotion/EasyMotion.vim file. There, we can find a section,

" == Default key mapping {{{
if g:EasyMotion_do_mapping == 1
    " Prepare Prefix: {{{
    if exists('g:EasyMotion_leader_key')
        exec 'map ' . g:EasyMotion_leader_key . ' <Plug>(easymotion-prefix)'
    else
        if !hasmapto('<Plug>(easymotion-prefix)')
            map <Leader><Leader> <Plug>(easymotion-prefix)
        endif
    endif
    "}}}

where you can see it will only use the default if !hasmapto('<Plug>(easymotion-prefix)'), which is why

    map <S-Enter> <Plug>(easymotion-prefix)

fixes your problem.

I'm curious why

let g:EasyMotion_leader_key <S-Enter>

doesn't also work

In general

In general, it may be easier to do a word search in the help file or plugin file for <Plug> or <Leader><Leader>.

Another candidate is maplocalleader. vim-orgmode frustrated me with overwriting my use of leader key, so I have let maplocalleader='\' to alleviate what may be common to other plugins as well.

Upvotes: 2

Related Questions