Sunday, January 5, 2014

Re: Remap while completion popup is visible

On Saturday, January 4, 2014 5:47:29 PM UTC+4, Matteo Landi wrote:
> Hi Everyone,
>
> I would like to remap the <Tab> key so that vim will automatically pick the current selected item from the completion popup.  I thought it would have been easy but was wrong;  here is what I added to my .vimrc file:
>
>   inoremap <expr> <Tab> pumvisible() ? "\<C-Y>" : "\<Tab>"
>
> Vim still keeps adding tabs rather than closing the completion popup.  Is it something wrong with that?  Maybe other plugins interfering?  I even found at least two different resources where something like this is done, but none of them worked.

Works for me. Can you show what exactly did you type, what you expected to see as a result and what you saw.

Note that `"\<C-y>"` here actually produces string `"\"\\\<C-y>\""` instead of `"\"\\<C-y>\""`. I.e. <C-y> gets replaced with control character *before* string evaluation happens meaning that backslashes are useless here. Since backslash-escaped control character inside double quotes is just control character this does not do any harm *except* for misguiding reader about <C-y> handling in this case: it is handled when doing :map argument expansion and not expression evaluation.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: