Photocatalytic water splitting holds great potential for transforming solar energy into valuable chemical products. However, obstacles such as the rapid recombination of electron-hole pairs and insufficiently active surface areas of photocatalysts remain significant challenges. In this study, we present the first demonstration that lithium bis(trifluoromethanesulfonyl)imide vapor successfully etches aluminum from Nb2AlC MAX phase powders while concurrently forming NbO2F anchors on Nb2CTx nanosheet (Nb2CTxNS) MXene, leading to the in situ formation of a Nb2CTxNS/NbO2F heterostructure composite. This novel material exhibits a remarkable photoelectrochemical performance, achieving a current density of 252 μA cm-2, which is 1000 and 10 times greater than those of Nb2AlC MAX and Nb2C nanosheet MXene, respectively. These findings shed light on innovative approaches for developing photocatalytic materials via vapor-assisted synthesis, offering a promising pathway for advancing material discovery in both photo- and energy-related fields.