1

I want to change the key mapping when I run CtrlP. For example, if I press ctrl+p to run CtrlP, type in something, and try to move the cursor to choose a file, I want to use ctrl+j to move down, and ctrl+k to move up.

Is this possible? How can I change the key mapping in the CtrlP window?

1

You can use the dictonary variable g:ctrlp_prompt_mappings that is read by CtrlP. You just need to specify the keys you want to change. Read :h g:ctrlp_prompt_mappings for more info.

In order to get what you describe in your question try this in your vimrc file:

let g:ctrlp_prompt_mappings = {
  \ 'PrtSelectMove("j")':   ['<c-j>', '<down>'],
  \ 'PrtSelectMove("k")':   ['<c-k>', '<up>'],
  \ }

But that is already the default. Maybe you want to switch j and k (did I misread your question?) so you can try it the other way round if you want:

let g:ctrlp_prompt_mappings = {
  \ 'PrtSelectMove("j")':   ['<c-k>', '<down>'],
  \ 'PrtSelectMove("k")':   ['<c-j>', '<up>'],
  \ }

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.