By employing atomistic computer simulations with empirical potential and density functional force models, we study B∕N ion implantation onto carbon nanotubes. We simulate irradiation of single-walled nanotubes with B and N ions and show that up to 40% of the impinging ions can occupy directly the sp2 positions in the nanotube atomic network. We further estimate the optimum ion energies for direct substitution. Ab initio simulations are used to get more insight into the structure of the typical atomic configurations which appear under the impacts of the ions. As annealing should further increase the number of sp2 impurities due to dopant atom migration and annihilation with vacancies, we also study migration of impurity atoms over the tube surface. Our results indicate that irradiation-mediated doping of nanotubes is a promising way to control the nanotube electronic and even mechanical properties due to impurity-stimulated crosslinking of nanotubes.