The problem with the IDE is everyone wants it to do everything... Formatting, auto-spacing, syntax checking, text colorization, Key word completion, all upper case keywords... No wait, let's scratch that and make those optional. Optional underscores, debugging features, option explicit checking... And on and on and on!!
And all of this built over a framework that translates your code to c and writes it to disk *with every keystroke*!
It all leads to lag in the IDE as you describe, and the longer the code, the greater the lag.
And honestly, you can just expect the issue to grow worse as ever more features are added and inserted into the IDE. Folks want it to do EVERYTHING, but as more and more gets added, the upper size limit decreases with which you can realistically do ANYTHING. Which is why I've been migrating over to a secondary IDE for large projects more and more with each version released. 😉