Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you automatically remove the preview window after autocompletion in Vim?

I'm using omnifunc=pythoncomplete. When autocompleting a word (e.g., os.<something>), I get the list of eligible class members and functions, as expected, as well as a scratch buffer preview window with documentation about the selected member or function. This is great, but after selecting the function I want, the preview window remains.

I can get rid of it with :pc, but I'd like it just to automatically disappear after I've selected my function, a la Eclipse. I've played around with completeopt but to no avail.

like image 483
Ben Davini Avatar asked Jun 23 '10 20:06

Ben Davini


3 Answers

Put the following in your vimrc:

" If you prefer the Omni-Completion tip window to close when a selection is
" made, these lines close it on movement in insert mode or when leaving
" insert mode
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
like image 109
gotgenes Avatar answered Nov 20 '22 15:11

gotgenes


Even though there is already an accepted answer I found this directly from the docs which will work for any plugin that is having this issue.

autocmd CompleteDone * pclose
like image 23
Dan Bradbury Avatar answered Nov 20 '22 15:11

Dan Bradbury


If you have the supertab plugin installed, there is an option called supertab-closepreviewonpopupclose.

Put the following in your .vimrc:

let g:SuperTabClosePreviewOnPopupClose = 1
like image 19
Profpatsch Avatar answered Nov 20 '22 14:11

Profpatsch