Improve word matching

Connected to #2, incomplete highlights sometimes appeared in template
variables.