views:

97

answers:

2

I'm using omnifunc=pythoncomplete. When autocompleting a word (e.g., os.), 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.

A: 

You could throw in the following mappings to have certain keys try to close the preview window.

inoremap <space> <C-O>:wincmd z<CR><space>
inoremap ( <C-O>:wincmd z<CR>(
inoremap ) <C-O>:wincmd z<CR>)
inoremap , <C-O>:wincmd z<CR>,
inoremap <CR> <C-O>:wincmd z<CR><CR>
inoremap <esc> <esc>:wincmd z<CR>

You could also use autocommands to close the preview window when you're finished in insert mode:

augroup GoAwayPreviewWindow
autocmd! InsertLeave * wincmd z
augroup end
too much php
+2  A: 

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
gotgenes
Worked like a charm. Thanks!
Ben Davini