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

前端 未结 7 689
执笔经年
执笔经年 2021-01-29 18:05

I\'m using omnifunc=pythoncomplete. When autocompleting a word (e.g., os.), I get the list of eligible class members and functions, as

相关标签:
7条回答
  • 2021-01-29 18:34

    You can type that in the .vimrc:

    set completeopt-=preview
    
    0 讨论(0)
  • 2021-01-29 18:37

    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
    
    0 讨论(0)
  • 2021-01-29 18:39

    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
    
    0 讨论(0)
  • 2021-01-29 18:53

    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
    
    0 讨论(0)
  • 2021-01-29 18:53

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

    Put the following in your .vimrc:

    let g:SuperTabClosePreviewOnPopupClose = 1
    
    0 讨论(0)
  • 2021-01-29 18:53

    I know this question is very old, but after days of looking for a "clean" solution I just found the CompleteDone autofunction that does the job:

    au CompleteDone * pclose
    
    0 讨论(0)
提交回复
热议问题