General theory of vortices