I agree that you should never vaccum a reef tank. Fish and inverts should be stirring your sand. Or manually as noted above.
In a more heavily populated tank with sand though, and you absolutely have to vaccum, you can use a siphon with a long chamber using a two handed technique:
- start the siphon
- One hand on vaccum, other goes on the tubing
- fill tube with sand
- crimp the tubing to stop the flow of water and pull vaccum out of the sand (still underwater)
- sand will settle and detritus will stay in solution
- release the tubing to clear the vaccum
- repeat steps 2-5 as necessary
It takes some practice, but can be done. You will probably still lose a small amount of sand, though minimal...