在我的.vimrc文件,我有以下功能,即褶皱上的一些.hpp.cpp文件顶部的许可信息:

" Skip license 
function! FoldLicense()
    if !exists("b:foldedLicense")
        let b:foldedLicense = 1
        1;/\*\//fold
    endif
endfunction

au BufRead *.hpp call FoldLicense()
au BufRead *.cpp call FoldLicense()

这个效果很好,但如果我打开其中一个.cpp文件未有任何授权的信息块,Vim会抱怨说,该模式是的未找到的。合理,但有没有办法让他停止抱怨,刚刚的无助的如果模式没有发现?

谢谢!

编辑:完全溶液(使用布赖恩罗斯回答)

" Skip license 
function! FoldLicense()
    if !exists("b:foldedLicense")
        let b:foldedLicense = 1
        silent! 1;/\*\//fold
    endif
endfunction

au BufRead *.hpp call FoldLicense()
au BufRead *.cpp call FoldLicense()
有帮助吗?

解决方案

我相信这可能工作:

silent! 1;/\*\//fold
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top