VIM + Syntastic:如何禁用检查器?

时间:2022-04-12 01:54:26

I'm using Syntastic which is enabled for my HTML files. Since I have a very big file with "validator w3" checkers enabled, GVIM or VIM became very slow while saving the file (:w).

我使用的是Syntastic,它支持我的HTML文件。由于我有一个很大的文件,启用了“validator w3”检查程序,所以GVIM或VIM在保存文件时变得非常慢(:w)。

Is it possible to toggle syntastic off temporally just for the current session?

是否可以在当前会话中暂时切换syntastic off ?

9 个解决方案

#1


134  

Using :SyntasticToggleMode you can toggle Syntastic into passive mode, which will disable auto-checking. You can then check a file by running :SyntasticCheck instead.

使用:SyntasticToggleMode你可以切换到被动模式,这将禁用自动检查。然后可以运行:SyntasticCheck来检查文件。

For more, see :help syntastic-commands

更多信息,请参见:帮助语法命令

On another note: if syntastic is slow for you, and you've switched to NeoVim, consider trying Neomake as an alternative. Unlike Syntactic it runs asynchronously, so even if it's slow it shouldn't hinder you.

另一个注意事项:如果syntastic对你来说很慢,而且你已经改用NeoVim,考虑试试Neomake作为替代。与语法不同,它是异步运行的,所以即使它很慢,它也不会妨碍你。

#2


75  

I have disabled Syntastic by default and activate/disable error checking with the following in my .vimrc:

我在默认情况下禁用了Syntastic,并在.vimrc中激活/禁用错误检查:

let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>

When I need to use error checking I simply hit: ctrl-w E

当我需要使用错误检查时,我只需按下:ctrl-w E

#3


31  

Alternative to Jamie and gospes answers, one can disable the checker completely by specifying the checker like so:

除了Jamie和gospes的答案之外,还可以通过如下方式指定checker来完全禁用该checker:

let g:syntastic_html_checkers=['']

Also make sure the syntastic_check_on_open isn't set to 1, which will countermand the above line:

还要确保syntastic_check_on_open没有设置为1,这将抵消上面一行:

let g:syntastic_check_on_open = 0

#4


8  

You could turn Syntastic off for the entire session (as answered by Jamie Schembri), but if it's just a problem with the one "very big file", you may want to disable just the one buffer.

您可以关闭整个会话的Syntastic (Jamie Schembri的回答),但是如果只是一个“非常大的文件”的问题,您可能想要禁用一个缓冲区。

A few of the files I work on at my job are hopelessly non-PSR compliant. Most work just fine. I was looking for functionality to disable Syntastic for just those problem files. A simpler form of the 'SyntasticDisableToggle' solution outlined by the primary contributor works for me:

在我的工作中,有一些文件是完全不符合psr的。大多数工作的很好。我正在寻找功能,以禁用这些问题文件的Syntastic。主要贡献者列出的“SyntasticDisableToggle”解决方案的一种更简单的形式对我有用:

"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()

Because this doesn't affect other buffers, I can keep using this awesome plugin for any other (partially) compliant files I have open.

因为这不会影响到其他缓冲区,所以我可以继续对我打开的任何其他(部分)兼容的文件使用这个很棒的插件。

#5


5  

The following settings worked for me.

以下设置对我有效。

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'}

#6


5  

This doesn't directly address the question, but can help beyond the current session. If you have a file that you must edit often but which you know that you will always want to disable Syntastic on (e.g. it has thousands of errors and you intend not to fix them, and leaving it on results in UI slowdown), then permanently blacklisting it is very convenient.

这并不能直接解决这个问题,但可以帮助解决当前会议之外的问题。如果你有一个文件,您必须编辑经常,但你知道你总是想禁用Syntastic(例如它有成千上万的错误和你打算不去解决问题,并离开导致UI放缓),然后永久黑名单很方便。

To do this, use the syntastic_ignore_files option. It's tucked away in the help, but you can use regexes with this feature to blacklist files.

为此,请使用syntastic_ignore_files选项。它隐藏在帮助中,但是您可以使用regexes将该特性列入黑名单。

                                                    '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$']

#7


3  

Another option to turn off checking for a single buffer (regardless of filetype) is to use :let b:syntastic_mode="passive". Since it isn't a toggle, it will work even if the buffer is currently in passive mode.

关闭对单个缓冲区的检查(不管文件类型)的另一个选项是:让b:syntastic_mode=“passive”。由于它不是切换,即使缓冲区当前处于被动模式,它也能工作。

If you want to temporarily turn off checking of all filetypes in all buffers, you can use :bufdo let b:syntastic_mode="passive". I have setup mappings to turn off/on checking of all buffers:

如果要临时关闭对所有缓冲区中所有文件类型的检查,可以使用: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>

This is particularly helpful when doing :wqa with a lot of open buffers.

这在做的时候特别有用:wqa具有大量的开放缓冲区。

#8


0  

Thanks for Steven Lu, I can ignore the files of Ansible Roles, now.

感谢Steven Lu,我现在可以忽略Ansible Roles的文件了。

" ignore files of Ansible Roles.
let g:syntastic_ignore_files = ['\m^roles/']

#9


0  

Similarly to those mentioned by a few others, here's a vimrc segment that will turn off Syntastic by default, but maps a button (here, F10) to check the current file, and uses the same button as a toggle to turn off the checks. It's a little slow, but works.

类似地,这里有一个vimrc段,它会在默认情况下关闭Syntastic,但是映射一个按钮(这里,F10)来检查当前文件,并使用与toggle相同的按钮来关闭检查。有点慢,但是很有效。

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>

#1


134  

Using :SyntasticToggleMode you can toggle Syntastic into passive mode, which will disable auto-checking. You can then check a file by running :SyntasticCheck instead.

使用:SyntasticToggleMode你可以切换到被动模式,这将禁用自动检查。然后可以运行:SyntasticCheck来检查文件。

For more, see :help syntastic-commands

更多信息,请参见:帮助语法命令

On another note: if syntastic is slow for you, and you've switched to NeoVim, consider trying Neomake as an alternative. Unlike Syntactic it runs asynchronously, so even if it's slow it shouldn't hinder you.

另一个注意事项:如果syntastic对你来说很慢,而且你已经改用NeoVim,考虑试试Neomake作为替代。与语法不同,它是异步运行的,所以即使它很慢,它也不会妨碍你。

#2


75  

I have disabled Syntastic by default and activate/disable error checking with the following in my .vimrc:

我在默认情况下禁用了Syntastic,并在.vimrc中激活/禁用错误检查:

let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>

When I need to use error checking I simply hit: ctrl-w E

当我需要使用错误检查时,我只需按下:ctrl-w E

#3


31  

Alternative to Jamie and gospes answers, one can disable the checker completely by specifying the checker like so:

除了Jamie和gospes的答案之外,还可以通过如下方式指定checker来完全禁用该checker:

let g:syntastic_html_checkers=['']

Also make sure the syntastic_check_on_open isn't set to 1, which will countermand the above line:

还要确保syntastic_check_on_open没有设置为1,这将抵消上面一行:

let g:syntastic_check_on_open = 0

#4


8  

You could turn Syntastic off for the entire session (as answered by Jamie Schembri), but if it's just a problem with the one "very big file", you may want to disable just the one buffer.

您可以关闭整个会话的Syntastic (Jamie Schembri的回答),但是如果只是一个“非常大的文件”的问题,您可能想要禁用一个缓冲区。

A few of the files I work on at my job are hopelessly non-PSR compliant. Most work just fine. I was looking for functionality to disable Syntastic for just those problem files. A simpler form of the 'SyntasticDisableToggle' solution outlined by the primary contributor works for me:

在我的工作中,有一些文件是完全不符合psr的。大多数工作的很好。我正在寻找功能,以禁用这些问题文件的Syntastic。主要贡献者列出的“SyntasticDisableToggle”解决方案的一种更简单的形式对我有用:

"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()

Because this doesn't affect other buffers, I can keep using this awesome plugin for any other (partially) compliant files I have open.

因为这不会影响到其他缓冲区,所以我可以继续对我打开的任何其他(部分)兼容的文件使用这个很棒的插件。

#5


5  

The following settings worked for me.

以下设置对我有效。

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'}

#6


5  

This doesn't directly address the question, but can help beyond the current session. If you have a file that you must edit often but which you know that you will always want to disable Syntastic on (e.g. it has thousands of errors and you intend not to fix them, and leaving it on results in UI slowdown), then permanently blacklisting it is very convenient.

这并不能直接解决这个问题,但可以帮助解决当前会议之外的问题。如果你有一个文件,您必须编辑经常,但你知道你总是想禁用Syntastic(例如它有成千上万的错误和你打算不去解决问题,并离开导致UI放缓),然后永久黑名单很方便。

To do this, use the syntastic_ignore_files option. It's tucked away in the help, but you can use regexes with this feature to blacklist files.

为此,请使用syntastic_ignore_files选项。它隐藏在帮助中,但是您可以使用regexes将该特性列入黑名单。

                                                    '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$']

#7


3  

Another option to turn off checking for a single buffer (regardless of filetype) is to use :let b:syntastic_mode="passive". Since it isn't a toggle, it will work even if the buffer is currently in passive mode.

关闭对单个缓冲区的检查(不管文件类型)的另一个选项是:让b:syntastic_mode=“passive”。由于它不是切换,即使缓冲区当前处于被动模式,它也能工作。

If you want to temporarily turn off checking of all filetypes in all buffers, you can use :bufdo let b:syntastic_mode="passive". I have setup mappings to turn off/on checking of all buffers:

如果要临时关闭对所有缓冲区中所有文件类型的检查,可以使用: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>

This is particularly helpful when doing :wqa with a lot of open buffers.

这在做的时候特别有用:wqa具有大量的开放缓冲区。

#8


0  

Thanks for Steven Lu, I can ignore the files of Ansible Roles, now.

感谢Steven Lu,我现在可以忽略Ansible Roles的文件了。

" ignore files of Ansible Roles.
let g:syntastic_ignore_files = ['\m^roles/']

#9


0  

Similarly to those mentioned by a few others, here's a vimrc segment that will turn off Syntastic by default, but maps a button (here, F10) to check the current file, and uses the same button as a toggle to turn off the checks. It's a little slow, but works.

类似地,这里有一个vimrc段,它会在默认情况下关闭Syntastic,但是映射一个按钮(这里,F10)来检查当前文件,并使用与toggle相同的按钮来关闭检查。有点慢,但是很有效。

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>