Tuesday, July 17, 2012

Re: Scripting the enter key

On Monday, July 16, 2012 5:32:35 PM UTC-5, skeept wrote:
>
> By coincidence I was also trying to fix the problem that these two plugins conflict by both defining a imap for the enter key.
> The closest I got was to add the following to a file after/plugin/
>
> imap <silent> <cr> <Plug>delimitMateCR<C-R>=<SNR>34_SelectCompletion(1)<CR>
>
> this would be the mapping defined by delimitmate followed by the mapping defined by supertab.
> This solution doesn't really work, whenever I press enter two new lines are entered and the braces in the expansion are not correctly aligned.
> The other way around doesn't work (when I put the mapping from supertab before the mapping from delimitmate).
>
> Right now I gave up on the mapping for delimitmate and I am just using the mapping for supertab and additionally have the following map:
>
> inoremap {{ {<cr><cr>}<esc>kcc
>
> if anyone has any idea on how to have the <cr> key work for both plugins it would be nice, otherwise I'll stick to this mapping, once I get used to it is not bad.
>

I assume your problem is with selecting a result from a completion menu using <CR>. Try using the pumvisible() function in an expression mapping, to return either the delimitMate mapping or the SuperTab mapping depending on whether the completion menu is visible.

I don't use SuperTab, but I use the following:

" always insert a completion menu item with <Enter>
imap <expr> <CR> pumvisible() ? "\<LT>C-Y>" : "\<Plug>delimitMateCR"

You may be able to replace the first return value with the supertab mapping. Or maybe you don't even need the supertab mapping if you use the above, I'm not sure what supertab does when you press <CR>.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment