Working on tab autocomplete

Previously autocomplete did not completely overwrite the word, but
only up to the caret.  This resulted in replacements stacking up,
which looked strange and was incorrect behavior.  Now the replacement
checks for the entire word, and this results in the expected
behavior.

This also moves some of the variables off of the AngularJS scope.
Not all of the data needs to be on the scope, so this prevents
leaking of data which can remain within the local JS scope.

Autocompletion works as intended if the caret is placed at or within
the last word.  It also works as intended if the caret is placed
within the word that should be processed, or at the begining of the
word.  If the caret is placed at the end of the word, the word
proceeding the caret is processed.  This is incorrect behavior.