在我的.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()
Run Code Online (Sandbox Code Playgroud)
这种运作良好,但如果我打开.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()
Run Code Online (Sandbox Code Playgroud)