Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim pumvisible() call putting in random text

Tags:

vim

I'm using the spf13 package for Vim. However, whenever I enter some text and press escape, some weird characters get appended to it.

For example, if I type this and press escape,

hello

I get this:

hellopumvisible() ? "\" : "\

There is a mapping on my .vimrc file that reads like this, which I think might be responsible:

" some convenient mappings
inoremap <expr> <Esc>      pumvisible() ? "\<C-e>" : "\<Esc>"
inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <Down>     pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up>       pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <C-d>      pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u>      pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"

I guess it's taken from http://vim.wikia.com/wiki/Improve_completion_popup_menu. But for some reason, this is giving me odd behavior. Any advice?

EDIT: Here's the output of :inoremap <esc>

i <Esc> *@pumvisible() ? '<C-E>' : '<C-R>=<SNR>32_FlushBuffer()<CR>pumvisible() ? "\<C-E>" : "\<Esc>"'

i <Esc> * pumvisible() ? "\<C-E>" : "\<Esc>"

And I'm using Vim 7.3 on Windows 8.

Solution

The autoclose plugin is interfering with mapping. I've written the steps to remove it here: http://crossplatform.net/dev/vim-spf13-writes-random-characters-when-pressing-escape.html. It works fine now.

like image 922
AgilE Avatar asked Nov 29 '12 08:11

AgilE


2 Answers

Probably, this maybe FAQ. And this will be helpful for others. So I copied answer from comment line above.

When you have a problem about vim mappings.

Check :verbose inoremap at the first.

If you know the keys which have problem, then do it with specified key, for example :verbose inoremap <esc>.

like image 108
mattn Avatar answered Nov 14 '22 01:11

mattn


This fixes it for me, in your ~/.vimrc or ~/.config/nvim/init.vim file add:

let g:AutoClosePreserveDotReg = 0
like image 9
dominic Avatar answered Nov 14 '22 00:11

dominic