Search code examples
linuxvimpylintpython-mode

automatically close pylint window after python code window is close in VIM


How can I set automatically close pylint window after python code window is close in VIM?

Every time I quit from vim, but pylint window still displayed.

I want to automatically close pylint warning window when I quit from python code.

I know the way to doing this by manually is :qa!


Solution

  • Assuming the pylint window shows a scratch buffer, you can close this automatically via an :autocmd:

    :autocmd WinEnter * if winnr('$') == 1 && ! empty(&buftype) && ! &modified | quit | endif
    

    When you :quit, you either exit Vim or enter another open window. Above checks that this is a single window containing a scratch buffer with unpersisted changes, and then quits that, too. This should give you the general idea; you can tweak the conditions to better suit your needs.