Is "don't" considered informal In writing? Originally, I thought that all contractions are informal, but I remember later I saw "don't" also used in formal writings, or am I wrong? Thanks!
I would use "don't" in all but the most formal of writing. (Like, wedding invitations, an academic paper). Certainly for things like: a business letter, a note that you put on your door, an e-mail to someone you respect, etc., contractions are fine and failure to use them will make your writing sound overly formal.
Even in formal writing, which I occasionally have to do, I try to slip in "don't" and "can't" unless an editor catches me.
I don't like the comparison to swearing at all. As a foreign language learner you should basically never swear unless you are completely familiar with who you are talking to and you are using only words that they already used in similar contexts; otherwise you face a grave risk of offending them. But half of the native English speakers don't even know the "rule" that contractions are informal. You should definitely learn to use them all the time.