The melakha of Tofer (sewing) refers to binding together curtains or material in a manner similar to the way the curtains were sewn for the Mishkan. The difference between Tofer and Boneh is that the former refers to joining soft objects together, while the latter refers to joining hard objects together.
One who sews two stitches in a way that the stitches will last transgresses the Torah prohibition of Tofer. If the stitches will only last temporarily, he transgresses a rabbinic prohibition (Shabbat 74b; MB 340:27).
Similarly, one may not tighten a thread that is starting to unravel. If this tightening will last, it is prohibited by Torah law; if it is temporary, the prohibition is rabbinic (Shabbat 75a; SA 340:6). Similarly, if a button comes loose, one may not pull its thread to tighten it (SSK 15:71).
One may join two parts of a garment together using buttons and buttonholes, zippers, snaps, or Velcro. One may do so even if he intends to leave them closed for an extended period of time. These connections are made to open and shut, so the prohibitions of sewing and tearing do not apply to opening and shutting them, just as the prohibitions of building and destroying are not relevant to opening and shutting windows or doors (see below 15:3).
One may pull on a drawstring to tighten a hood or jacket, because this is not sewing but normal use of the clothing. Additionally, using the drawstring is different from sewing since it is generally threaded very loosely through its casing. One may also pull closed a drawstring that is threaded through loops at the waist (see SA 340:7).
One may connect two parts of an item of clothing with a safety pin, since this does not resemble sewing. Some are stringent about this, but the halakha follows the lenient position. One who is stringent and refrains from using a safety pin that he plans to leave in for an extended period of time should be commended. In contrast, a brooch may be attached to clothing, even for an extended period, because it does not connect two pieces of cloth.
Just as sewing is prohibited by Torah law, so is attaching one thing to another, which is a tolada of Tofer. Therefore, one may not attach papers or pieces of cloth to one another. If the attachment is long lasting, it is prohibited by Torah law, while if it is temporary the prohibition is rabbinic (see SHT 303:68).
Similarly, it is forbidden by Torah law to staple papers together. Since the staple connects the papers with two holes, this is like sewing two stitches. But one may hold papers together with a paper clip, since this is an external connector and does not really join them together at all.