The Vilsmeier formylation involves the reaction of heterocycles rich in electron density with dimethylformamide in the presence of phosphorus oxytrichloride.
vilsmeier-pyrrol-01
Mechanism:
 
Stage 1. Formation of the Vilsmeier electrophile
vilsmeier-pyrrol-02
Stage 2. Nucleophilic attack of pyrrole on the Vilsmeier electrophile
vilsmeier-pyrrol-03
Stage 3. Recovery of aromaticity
vilsmeier-pyrrol-04
Stage 4. Formation of the immonium salt
vilsmeier-pyrrol-05