title: vim syntax highlighting: match, contains
body: <p>I am trying to make an angularjs syntax highlighting file for vim.  A piece of the file is:</p>
  
  <pre><code>syn match ngMethods                /\.[0-9A-Za-z_\-\$]\+\s*\((\|=\)/ contains=AngularMethods
  syn keyword AngularMethods         contained $addControl $anchorScroll $animate ...
  
  syn match ngObjMethods             /^\s*[0-9A-Za-z_\-\$]\+\s*:/ contains=AngularObjectMethods
  syn keyword AngularObjectMethods   contained compile controller link ...
  </code></pre>
  
  <p>etc...</p>
  
  <p>Down below I have:</p>
  
  <pre><code>hi def link AngularMethods       Function
  
  hi def link AngularObjectMethods Function
  </code></pre>
  
  <p>The first regular expression (for <code>AngularMethods</code>) is supposed to capture things like <code>$addControl</code> in the following:</p>
  
  <pre><code>myelement.$addControl()
  myelement.$addControl = function ()
  </code></pre>
  
  <p>The second regular expression (for <code>AngularObjectMethods</code>) captures things like <code>compile</code> in:</p>
  
  <pre><code>    compile : function () {}
  </code></pre>
  
  <p>The <code>AngularMethods</code> one does NOT work but the latter one does.  Can anyone see the problem?  I've also tried using the regexes:</p>
  
  <pre><code>/\.\zs[0-9A-Za-z_\-\$]\+\ze\s*\((\|=\)/
  
  /\.[0-9A-Za-z_\-\$]\+\s*\((\|=\)\@=/
  </code></pre>
  
  <p>The former matches the exact word.  The latter is something I saw in another syntax file.  Any ideas? Thanks for your help!</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Kent (below) was correct about the keyword.  This uncovered the real problem which is that I have another regex:</p>
  
  <pre><code>syn match ngProperties          /\.[0-9A-Za-z_\-\$]\+\s*[^(=]/ contains=AngularProperties
  syn keyword AngularProperties   contained $attr $dirty $error ...
  </code></pre>
  
  <p>which is supposed to be the complement of the ngMethods regex.  If I comment out the <code>ngProperties</code> regex, the <code>ngMethods</code> regex works.  This means <code>ngProperties</code> is bad.  It is supposed to catch things like <code>$attr</code> in:</p>
  
  <pre><code>var myAttribute = element.$attr;
  </code></pre>
  
  <p>I will try to fix this.  Can someone post the correct regex just in case?</p>