The porosity and heteroatom doping of carbon materials are crucial for their adsorption capacity and selectivity toward CO2. Herein, nitrogen-doped microporous carbon nanofibers (CNFs) were prepared by carbonizing electrospun polyacrylonitrile (PAN) nanofibers, using nitrogen-rich polyvinylpyrrolidone (PVP) as porogen and nitrogen source simultaneously. The synergistic effect of pore generation and nitrogen doping improved the porosity and preserved a substantial nitrogen content in the CNFs. Compared to the nitrogen-free polyethylene glycol (PEG) porogen, the incorporation of PVP can facilitate nitrogen doping during the carbonization process. With an increasing amount of PVP addition, the specific surface area of the CNFs significantly expanded to 410 m2/g, maintaining a high nitrogen content of 10.32 wt%. The porosity and nitrogen functionalities (Pyridinic N and pyrrolic N) collaborated synergistically in determining CO2 adsorption capacity, with elevated nitrogen content resulted in improved selectivity. The CNFs exhibited remarkable IAST CO2/N2 (10:90) selectivity of 38 and cycling stability, demonstrating their potential for long-term practical applications. This work provides unique inspiration for the design of porous nanofibers with exceptional CO2 adsorption capacity and selectivity.