Imagine I just typed `Hea' and the completion popup pops in with the wollowing words: Head, Hearst, Heath, Heather and Heaviside. To autocomplete with `Heater' I would move the selection to the right line using arrow keys or <C-N>/<C-P> and then would confirm the action with either Enter or <C-Y>.
What happens with the mapping above? When I press <Tab> to confirm the autocompletion, Vim closes the completion popup and insert a space at the end -- leaving me with `Hea ' instead of `Heather'.On Sun, Jan 5, 2014 at 7:03 PM, ZyX <zyx.vim@gmail.com> wrote:
On Saturday, January 4, 2014 5:47:29 PM UTC+4, Matteo Landi wrote:Works for me. Can you show what exactly did you type, what you expected to see as a result and what you saw.
> 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.
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.
--
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:
Post a Comment