When you paste or delete words, TextEdit can insert or delete spaces around them to ensure the correct amount of spacing remains. This feature is called “smart copy/paste.”
To use smart copy/paste:
Choose Edit > Substitutions, and then select Smart Copy/Paste from the submenu.
To automatically use smart copy/paste in all new documents, choose TextEdit > Preferences, click New Document, and then select “Smart copy/paste” below Options.
To paste or cut exactly what’s selected:
Choose Edit > Substitutions and deselect Smart Copy/Paste in the submenu.