How-to handle errors in Vim Script ?

Posted by ereOn on Stack Overflow See other posts from Stack Overflow or by ereOn
Published on 2010-05-17T09:17:27Z Indexed on 2010/05/17 9:20 UTC
Read the original article Hit count: 158

Filed under:
|
|

In my .vimrc file, I have the following function, which folds the licensing information on the top of some .hpp and .cpp files:

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

This works well, but if I open a .cpp file which doesn't have any licensing information block, Vim complains that the pattern is not found. Fair enough, but is there a way so that he stops complaining and just does nothing if the pattern is not found ?

Thanks !

© Stack Overflow or respective owner

Related posts about vim

Related posts about vimrc