合成关闭错误窗口和原始文件窗口 [英] Syntastic close error window and original file window

查看:126
本文介绍了合成关闭错误窗口和原始文件窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从GitHub安装了Syntastic,并且试图使用Syntastic检查perl语法错误(并计划在短时间内用于Python).当我使用':quit'或':q'时,仅原始文件窗口关闭.错误窗口不会关闭.下面是我的.vimrc文件的片段:

I've installed Syntastic from GitHub and I'm trying to use Syntastic for checking perl syntax errors (and planning to use for Python in a short while). When I use ':quit' or ':q', only original file window closes. The error window does not close. Below is snip from my .vimrc file :

execute pathogen#infect()  
set statusline+=%#warningmsg#  
set statusline+=%{SyntasticStatuslineFlag()}  
set statusline+=%*  
let g:syntastic_perl_checkers = ['perl']  
let g:syntastic_python_checkers = ['pylint']  
let g:syntastic_enable_perl_checker = 1  
let g:syntastic_always_populate_loc_list = 1  
let g:syntastic_auto_loc_list = 1  
let g:syntastic_check_on_open = 1

由于我是vim脚本的新手,所以我想知道在原始文件窗口处于活动状态时使用':quit'或':q'时如何同时关闭窗口,错误窗口和原始文件窗口.

Since I'm very new to vim scripting, I would like to know how to close both windows, error window and original file window, when I use ':quit' or ':q' while original file window is active.

推荐答案

这是Vim的正常行为;与Syntastic无关. quickfix 位置列表窗口可能包含对其他文件的引用,因此不确定从原始窗口退出时是否要完全离开Vim.

That's the normal Vim behavior; it has nothing to do with Syntastic. The quickfix or location list windows may contain references to other files, so it is not certain that you want to completely leave Vim when quitting from the originating window.

最简单的解决方案是使用:qa(全部退出)而不是:q.由于错误窗口不包含未更改的更改,因此这是安全的,不需要确认.

The simplest solution is using :qa (quit all) instead of :q. As the error window doesn't contain unpersisted changes, this is safe and doesn't require a confirmation.

如果您不得不考虑这一点而感到烦恼,则可以使用Vim的脚本功能来更改其行为:

If you are annoyed by having to think about this, you can use Vim's scripting capabilities to change its behavior:

:autocmd WinEnter * if &buftype ==# 'quickfix' && winnr('$') == 1 | quit | endif

这会在每次窗口更改时检查是否仅剩一个窗口,如果该窗口是快速修复程序/位置列表,则会退出Vim.

This checks on each change of window whether there's only one window left, and if that one is a quickfix / location list, it quits Vim.

这篇关于合成关闭错误窗口和原始文件窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆