1

I'm using the easymotion plugin and mapping my arrow keys to do calls to easymotion. Concretely:

map <down> <Plug>(easymotion-w)
map <left> <Plug>(easymotion-F)
map <right> <Plug>(easymotion-bd-f)
map <up> <Plug>(easymotion-B)

This works as intended. Now I want it to work also in insert mode so I added:

imap <down> <Esc><down>
imap <left> <Esc><left>
imap <right> <Esc><right>
imap <up> <Esc><up>

Now in insert mode down and up work like the default keys (moving up and down) whereas right left have the intended behaviour. However, to me they seem equivalent mappings.

I've tried changing to imap <down> <Esc>dd, still does the default behaviour. If I put imap <left> <Esc>dd it deletes the line. So it may not be related to easymotion in particular.

Question 1 What is happening and how can I solve it?

Question 2: is this the most elegant/correct way to do mappings?

Note: at first I thought it may be affected by the time it takes to go from Insert to Normal mode, so I added the following piece of code that solves it:

set timeout " Do time out on mappings and others
set timeoutlen=2000 " Wait {num} ms before timing out a mapping
   "when press Esc to leave Ins mode it no longer takes a second
   "or another keystroke to leave Ins mode completely and update
   "the satus line.
set ttimeoutlen=0
augroup FastEscape:
    autocmd!
    au InsertEnter * set timeoutlen=0
    au InsertLeave * set timeoutlen=1000
augroup END
2
  • 5
    Another plugin is probably changing the <up> and <down> keys on InsertEnter. In insert mode, type: <c-o>:verbose imap <down>.
    – Tommy A
    Jan 11, 2017 at 2:43
  • @TommyA thanks! that's exactly what was happening
    – etal
    Jan 11, 2017 at 14:37

1 Answer 1

2

As @TommyA pointed out in the comments, a plugin was changing <up> and <down>. Turned out to be 'youcompleteme', in /autoload/youcompleteme.vim. There <up> <down> aren't explicitely mentioned, but they are called because they are part of the g:ycm_key_list_select_completion and g:ycm_key_list_previous_completion lists. Those lists were defined in youcompleteme/plugin/youcompleteme.vim, editing them solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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