folding - How-to handle errors in Vim Script? -


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

  "Skip the license function! FoldLicense () if! Exists (" b: foldedLicense " ) B two: add leakens = 1 1; / \ * \ // fold endiff end function Au BufRead *. HPP call FoldLicense () AU BufRead * .cpp call FoldLicense ()  

Works fine, but if I open a .cpp file which no If there is no licensing information block, then Vim complains that the pattern is not found is

thanks!

edit: complete, but a The way that he stops the complaints and just does nothing the solution (Answer by Brian Ross)

  "Leave the license function! Folder Licensing (if)! Exists ("B: Today license") B two: Today licensus = 1 silent! 1; / \ * \ // Fold the endifice end BufRead *. HPP call FoldLicense () AU BufRead * .cpp call FoldLicense ()  

I believe That it can work:

  Quiet! 1; / \ * \ // fold  

Comments