title: Indenting and JShint issues with extremely large JS files
body: <p>I am dealing with 15-20K line long JS files and I noticed that two things were happening</p>
  <ol>
  <li>when I auto indented a large block at some point the indentation would stop. At first, I thought there was some syntax error in that region but when I isolated that block of code the indentation would work fine</li>
  <li>JShint would make ludicrous assertions like <code>'xxx' is defined but not used</code>. A simple search showed that the variable was being used. I did not perform an exhaustive analysis, but all cases I did look at involved the variable being declared at the top of the page but used much later at the bottom of the page. When I copy/pasted the code block to the top of the page the problem would disappear</li>
  </ol>
  <p>As an experiment, I wrote a simple script like this one. It's too long to copy/paste here, but it can easily be created in vim using a macro. It can't be a coincidence that the error happened exactly after the 499'th function, can it? Is this a memory issue? A Plugin setting? An upper limit to the number of functions allowed in JS?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/* Before VIM formatting */
  (() =&gt; {
  var a1 = 1;
  var a2 = 2;
  var a3 = 3;
  /* Repeat 504 times */
  var a500 = 500;
  var a501 = 501;
  var a502 = 502;
  var a503 = 503;
  var a504 = 504;
  
  function print_a1 (){
  console.log (a1);
  }
  /* Repeat 504 times */
  
  function print_a499 (){
  console.log (a499);
  }
  function print_a500 (){
  console.log (a500);
  }
  function print_a501 (){
  console.log (a501);
  }
  function print_a502 (){
  console.log (a501);
  }
  function print_a503 (){
  console.log (a501);
  }
  function print_a504 (){
  console.log (a501);
  }
      
  });
  
  /* After VIM formatting (gg=G) */
  (() =&gt; {
      var a1 = 1;
      var a2 = 2;
      var a3 = 3;
      /* Repeat 504 times */
      var a500 = 500;
      var a501 = 501;
      var a502 = 502;
      var a503 = 503;
      var a504 = 504;
      
      function print_a1 (){
        console.log (a1);
      }
      /* Repeat 504 times */
      
      function print_a499 (){
        console.log (a499);
      }
  function print_a500 (){
  console.log (a500);
  }
  function print_a501 (){
  console.log (a501);
  }
  function print_a502 (){
  console.log (a501);
  }
  function print_a503 (){
  console.log (a501);
  }
  function print_a504 (){
  console.log (a501);
  }
      
  });</code></pre>
  </div>
  </div>
  </p>