【发布时间】:2010-05-17 09:17:27
【问题描述】:
在我的.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 会抱怨该模式找不到。很公平,但有没有办法让他停止抱怨,如果找不到模式,他就什么都不做?
谢谢!
编辑:完整解决方案(使用 Bryan Ross 回答)
" 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()
【问题讨论】: