Vancomycin targets bacterial cell wall synthesis by binding to the basic building block of the bacterial cell wall of Gram-positive bacteria, whether it is of aerobic or anaerobic class. Specifically, vancomycin forms hydrogen bonds with the -alanyl--alanine (-Ala--Ala) peptide motif of the peptidoglycan precursor, a crucial component of the bacterial cell wall.
Peptidoglycan is a polymer that provides structural support to the bacterial cell wall. The peptidoglycan precursor is synthesized in the cytoplasm and then transported across the cytoplasmic membrane to the periplasmic space, where it is assembled into the cell wall. The assembly process involves two enzymatic activities: transglycosylation and transpeptidation. Transglycosylation involves the polymerization of the peptidoglycan precursor into long chains, while transpeptidation involves the cross-linking of these chains to form a three-dimensional mesh-like structure.
Vancomycin inhibits bacterial cell wall synthesis by binding to the -Ala--Ala peptide motif of the peptidoglycan precursor, thereby preventing its processing by the transglycosylase; as such vancomycin disrupts the transglycosylation activity of the cell wall synthesis process. The disruption leads to an incomplete and corrupted cell wall, which makes the replicating bacteria vulnerable to external forces such as osmotic pressure, so that the bacteria cannot survive and are eliminated by the immune system.
Gram-negative bacteria are insensitive to vancomycin due to their different cell wall morphology. The outer membrane of Gram-negative bacteria contains lipopolysaccharide, which acts as a barrier to vancomycin penetration. That is why vancomycin is mainly used to treat infections caused by Gram-positive bacteria (except some nongonococcal species of Neisseria).
The large hydrophilic molecule of vancomycin is able to form hydrogen bond interactions with the terminal -alanyl--alanine moieties of the NAM/NAG-peptides. Under normal circumstances, this is a five-point interaction. This binding of vancomycin to the -Ala--Ala prevents cell wall synthesis of the long polymers of N-acetylmuramic acid (NAM) and N-acetylglucosamine (NAG) that form the backbone strands of the bacterial cell wall, and prevents the backbone polymers  from cross-linking with each other.