Vim close preview window after omnifunc selection
From Birnam Designs Wiki
Some omnifunc matches can show extended information in a scratch Preview window. This is especially useful after matching functions to show the function definition and parameters. To automatically close the preview window, though, you can use one or both of these in your .vimrc or .gvimrc file:
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif autocmd InsertLeave * if pumvisible() == 0|pclose|endif
Using only the second command is more useful for completing functions if the function definition is available in the scratch window.