1

I've tried this

au BufWinEnter * if &l:buftype != 'nofile' | map <buffer> <CR> <Plug>(easymotion-prefix) | endif

but somehow this isn't working (easymotion isn't working). While this works

au BufWinEnter * map <buffer> <CR> <Plug>(easymotion-prefix)
3

I'm not sure, but I think that | endif is in the {rhs} of the mapping command :map. To remove it, you could wrap the mapping in a chain and execute it, maybe like this:

au BufWinEnter * if &l:buftype != 'nofile' | exe "map <buffer> \<CR> \<Plug>(easymotion-prefix)" | endif
| improve this answer | |
1

Instead of toggling the global mapping, you could also define a (command-line window) buffer-local mapping for <CR> that restores the original functionality:

:autocmd CmdwinEnter * noremap <buffer> <CR> <CR>

This way, you can leave the plugin mapping alone, and do not need to duplicate its definition.

| improve this answer | |
  • Yeah, I guess that makes sense. However this would work only in cmdwindow, what if there are other usecases where buftype is 'nofile', like coming from plugins... – user1685095 Jan 12 '17 at 9:07
  • 1
    Plugin scratch buffers wouldn't profit from the default behavior of <CR>, so if they offer functionality on that key, they have already provided such buffer-local mapping which eclipses the global one [from easymotion]. The issue mainly is only with the command-line window, because of the special built-in behavior of <CR>. – Ingo Karkat Jan 12 '17 at 9:13
  • And again you right! – user1685095 Jan 12 '17 at 9:14
  • 1
    By any change do you know how to do the same for quickfix? au BufEnter * if &l:buftype != 'nofile' && &ft != 'quickfix' because this isnt' working for some reason. – user1685095 Jan 12 '17 at 19:04
  • 1
    @user1685095: I would use :au FileType qf – Ingo Karkat Jan 13 '17 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.