我正在使用Syntastic插件对我的HTML文件进行语法检查。由于启用了“validator w3”检查器的大型文件,GVIM或VIM在保存文件(:w)时变得非常缓慢。
是否可以在当前会话中暂时关闭Syntastic插件?
使用:SyntasticToggleMode
可以将Syntastic切换到被动模式,这将禁用自动检查。您可以通过运行:SyntasticCheck
来检查文件。
更多信息,请参见:help syntastic-commands
另外,如果您发现Syntastic速度较慢,请考虑尝试ale作为替代品。与Syntastic不同,它以异步方式运行,因此即使速度较慢,也不应该阻碍您的工作。
:error
或 Ctrl+Shift/Alt+e 在 :SyntasticCheck
和 :SyntasticToggleMode
之间切换。 - cintron:command Sd SyntasticToggleMode
然后在 vi 中按下 :Sd,它将禁用 Syntastic。有关如何执行此操作的更多信息,请参见此处:https://dev59.com/Gm865IYBdhLWcg3wTc3h - Eric Leschinskisilent! nmap <F6> :SyntasticToggleMode<CR>
。 - lfender6445我默认禁用了Syntastic,并使用以下内容在我的.vimrc文件中启用/禁用错误检查:
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR>
当我需要使用错误检查时,我只需按下:ctrl-w E
.vimrc
文件中。然而,如果我按下Ctrl-w E,Syntastic会弹出一秒钟然后消失。有什么想法是出了什么问题,或者如何跟踪解决这个问题? - Anticom除了Jamie和gospes的答案之外,还可以通过以下方式指定检查器来完全禁用检查器:
let g:syntastic_html_checkers=['']
syntastic_check_on_open
没有设置为1,否则会抵消上面的行:let g:syntastic_check_on_open = 0
你可以像Jamie Schembri所回答的那样,在整个会话中关闭Syntastic。但是,如果只是一个“非常大的文件”的问题,您可能希望仅禁用该缓冲区。
我在工作中处理的一些文件完全不符合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()
因为这不会影响其他缓冲区,所以我可以继续在我打开的任何其他(部分)兼容文件中使用这个很棒的插件。
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_ignore_files = ['\m^/tmp/bash-.*'
] - Anthony Geoghegan以下设置对我有效。
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片段,它默认关闭Syntastic,但映射了一个按钮(这里是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
特别有帮助。
我主要使用Ale和Syntastic,因为Rust Ale的支持还不太好。在我的情况下,我使用vim-plug软件包管理器,并进行设置,以使其不会自动启用任何这些插件。我使用了切换策略。
在我的情况下,我希望默认情况下使用Ale,并为Rust使用Syntastic
在vimrc的插件部分,我做了这个
Plug 'w0rp/ale', { 'on': 'ALEToggle' }
Plug 'vim-syntastic/syntastic', { 'on': 'SyntasticToggleMode' }
然后我设置了一个绑定来启用代码检查器(我使用 l 作为代码检查器的助记符)
nnoremap <leader>l :ALEToggle<CR>
对于Rust,我覆盖相同的绑定
au FileType rust noremap <buffer> <leader>l :SyntasticToggleMode<CR>
另外,我不得不从我的vimrc中删除statusline的内容,否则在禁用Syntastic时加载它会出现错误。
" Syntastic stuff
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
let g:rustfmt_autosave = 1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" Syntastic stuff
敬礼
" ignore files of Ansible Roles.
let g:syntastic_ignore_files = ['\m^roles/']
let g:syntastic_disabled_filetypes=['html']
,该命令可禁用 Syntastic 插件在 HTML 文件中的语法检查。 - yakiang