The mechanism of the reaction of melamine (C3H6N6) with ammonium metavanadate and the critical role of the surfactant in this reaction were investigated. The results indicate that the complex is obtained via the reaction of C3H6N6 with VO3- after the elimination of -NH2, and the surfactant can modulate the microstructure. In addition, a vanadium nitride/N,S co-doped carbon material fabricated from the above complex exhibits a specific capacitance of 422.0 F g-1 at 0.5 A g-1. This method provides a new route for the synthesis of vanadium nitride/carbon materials.