题
我正在使用为我的 HTML 文件启用的 Syntastic。由于我有一个非常大的文件,并且启用了“validator w3”检查器,因此在保存文件时 GVIM 或 VIM 变得非常慢 (:w)。
是否可以仅针对当前会话暂时关闭 Syntastic?
解决方案
使用 :SyntasticToggleMode
您可以将 Syntastic 切换到被动模式,这将禁用自动检查。然后您可以通过运行来检查文件 :SyntasticCheck
反而。
有关更多信息,请参阅 :help syntastic-commands
另一个注意事项:如果 Syntastic 对你来说很慢,请考虑尝试 麦酒 作为备选。与 Syntastic 不同的是,它是异步运行的,因此即使速度很慢也不会妨碍您。
其他提示
我默认情况下禁用语法,并在我的.vimrc中激活/禁用错误检查:
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>
.
当我需要使用错误检查时,我只是点击: ctrl-w e
jamie和gospes anslans的替代方案,一个可以完全禁用检查器完全,通过指定旋转检查旋转:
let g:syntastic_html_checkers=['']
.
还确保syntastic_check_on_open
未设置为1,这将逆应上述行:
let g:syntastic_check_on_open = 0
. 您可以为整个会话转动语音关闭(如 jamie schembri ),但如果这只是一个问题使用一个“非常大的文件”,您可能只想只禁用一个缓冲区。
我在我的工作中工作的一些文件是绝望的非psr兼容。大多数工作都很好。我正在寻找功能以禁用Syntastic的那些问题文件。主要贡献者概述的“ syntasticdisabledeggle '解决方法:
"disable syntastic on a per buffer basis (some work files blow it up)
function! SyntasticDisableBuffer()
let b:syntastic_skip_checks = 1
SyntasticReset
echo 'Syntastic disabled for this buffer'
endfunction
command! SyntasticDisableBuffer call SyntasticDisableBuffer()
.
因为这不会影响其他缓冲区,我可以继续使用我打开的任何其他(部分)兼容文件的这个令人敬畏的插件。
这并不能直接解决问题,但可以在当前会话之外提供帮助。如果您有一个必须经常编辑的文件,但您知道您总是希望禁用 Syntastic(例如它有数千个错误,并且您不打算修复它们,并且将其保留会导致 UI 变慢),然后将其永久列入黑名单非常方便。
为此,请使用 syntastic_ignore_files
选项。它隐藏在帮助中,但您可以使用具有此功能的正则表达式将文件列入黑名单。
'syntastic_ignore_files'
Default: []
Use this option to specify files that syntastic should never check. It's a
list of regular-expression patterns. The full paths of files (see ::p) are
matched against these patterns, and the matches are case sensitive. Use \c
to specify case insensitive patterns. Example:
let g:syntastic_ignore_files = ['\m^/usr/include/', '\m\c\.h$']
以下设置为我工作。
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
noremap <C-w>e :SyntasticCheck<CR>
noremap <C-w>f :SyntasticToggleMode<CR>
Ctrl-w + e shall enable checking
Ctrl-w + f shall disable checking
To disable warnings use:
let g:syntastic_quiet_messages={'level':'warnings'}
. 同样地与其他人提到的那些,这是一个vimrc段,默认情况下会关闭语法,但映射一个按钮(这里,f10)来检查当前文件,并使用相同的按钮作为切换关闭支票。它有点慢,但有效。
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = {'mode':'passive'}
nnoremap <F10> :SyntasticCheck<CR> :SyntasticToggleMode<CR> :w<CR>
. 关闭单个缓冲区检查(无论文件类型如何)的另一个选项是使用 :let b:syntastic_mode="passive"
. 。由于它不是切换,因此即使缓冲区当前处于被动模式,它也会工作。
如果您想暂时关闭对所有缓冲区中所有文件类型的检查,您可以使用 :bufdo let b:syntastic_mode="passive"
. 。我设置了映射来关闭/打开所有缓冲区的检查:
nnoremap <leader>sN :bufdo let b:syntastic_mode="passive"<cr>
nnoremap <leader>sY :bufdo unlet b:syntastic_mode<cr>
这在做时特别有帮助 :wqa
有很多打开的缓冲区。
感谢 Steven lu ,我可以忽略 ansible角色的文件。
" ignore files of Ansible Roles.
let g:syntastic_ignore_files = ['\m^roles/']
.