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.
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.
Probably, this maybe FAQ. And this will be helpful for others. So I copied answer from comment line above.
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>
.
This fixes it for me, in your ~/.vimrc or ~/.config/nvim/init.vim file add:
let g:AutoClosePreserveDotReg = 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With