Word isn’t really robust enough for this sort of thing. Better to use something like Sublime Text or BBEdit.
Of possible interest, an old thread on number -crunching: