You can pass a literal Ctrl+f
by pressing CtrlvCtrlf in insert mode, but I'm not sure this will work for you.
The other method which I find more correct (or easier and more widely used) is to pass the key/motion as a string and use :execute
to create the maps inside your function. Here is an example from the CtrlP plugin:
The part in the plugin:
if g:ctrlp_map != '' && !hasmapto('<plug>(ctrlp)')
exe 'map' g:ctrlp_map '<plug>(ctrlp)'
en
You can set the motion in .vimrc as:
let g:ctrlp_map = '<C-f>'
and then <plug>(ctrlp)
would be mapped to it.
In your case you would have a simple call in .vimrc like this:
nnoremap <c-p> :call Motion('<C-F>')<cr>
and in Motion
:
function Motion(sequence)
" other stuff
execute 'map' a:sequence '<Plug>(action)'
" more stuff
endfunction
<
with<lt>
, it solves a problem I had that may rely to this one – nobe4 Aug 28 '15 at 8:54