Wednesday, May 30, 2012

how to override original mapping ?

I want to let a new key bind override original map.
First give out the vimrc config snip.

imap <expr><Tab> neocomplcache#sources#snippets_complete#expandable() ?
\ "\<Plug>(neocomplcache_snippets_expand)"
\ : pumvisible() ? "\<C-n>"
\ : <SID>check_back_space() ? "\<TAB>"
\ : "\<C-x>\<C-u>"
inoremap <expr><C-n> neocomplcache#sources#snippets_complete#jumpable() ?
\ "\<Plug>(neocomplcache_snippets_jump)"
\ : "\<Tab>"
inoremap <expr><C-p> neocomplcache#sources#snippets_complete#expandable() ?
\ "\<Plug>(neocomplcache_snippets_expand)"
\ : pumvisible() ? "\<C-p>" : "\<Tab>"
imap <expr><C-j> "\<C-n>"
imap <expr><C-k> "\<C-p>"

What I want:
There is two situations:
1. select next item in popup menu. (I want to use <C-j>)
2. if it is in snippet placeholder. (I want to use <C-n> to jump.)
* When I'm in snippet placeholder, and I have popup menu to complete.
I hope <C-n> can only work for jump to next placeholder. And <C-j> only work
for select next item in popup menu.
Because <C-n> default is select next item in popup, so I want to override
it at somewhere. But <C-n> is used in upper inoremap and imap settings.
So I do not know how to do now.

--
[ stardiviner ] ^^&^^ {I hate all of you ! Leave me alone}
IRC(freeenode): stardiviner \\ Twitter: @numbchild \\
GnuPG Key fingerprint
>>> 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433

No comments: