For my specific case, the preview window was opened by plugins. So, I used plugin configuration to automatically close these windows.
Supertab
As suggested by Alex Kroll:
let g:SuperTabClosePreviewOnPopupClose = 1
YouCompleteMe
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 1
If the second variable is set, the first has no effect. From the docs:
The *g:ycm_autoclose_preview_window_after_completion* option
When this option is set to '1', YCM will auto-close the 'preview' window after
the user accepts the offered completion string. If there is no 'preview' window
triggered because there is no 'preview' string in 'completeopt', this option is
irrelevant. See the |g:ycm_add_preview_to_completeopt| option for more details.
Default: '0'
>
let g:ycm_autoclose_preview_window_after_completion = 0
<
-------------------------------------------------------------------------------
The *g:ycm_autoclose_preview_window_after_insertion* option
When this option is set to '1', YCM will auto-close the 'preview' window after
the user leaves insert mode. This option is irrelevant if
|g:ycm_autoclose_preview_window_after_completion| is set or if no 'preview'
window is triggered. See the |g:ycm_add_preview_to_completeopt| option for more
details.
Default: '0'
>
let g:ycm_autoclose_preview_window_after_insertion = 0
Ctrlless annoying is remappingCaps LocktoCtrlor swapping them if you want to keepCaps Lockavailable.jedi-vimhave optiong:jedi#auto_close_doc.g:SuperTabClosePreviewOnPopupClose (default 0)Looks like it's what you want:he supertab-closepreviewonpopupclose