The ground state electronic structure and the formation energies of both TiO2 and SrTiO3 nanotubes (NTs) containing CO, NO, SO, and FeTi substitutional impurities are studied using first-principles calculations. We observe that N and S dopants in TiO2 NTs lead to an enhancement of their visible-light-driven photocatalytic response, thereby increasing their ability to split H2O molecules. The differences between the highest occupied and lowest unoccupied impurity levels inside the band gap (HOIL and LUIL, respectively) are reduced in these defective nanotubes down to 2.4 and 2.5 eV for N and S doping, respectively. The band gap of an NO+SO codoped titania nanotube is narrowed down to 2.2 eV (while preserving the proper disposition of the gap edges relatively to the reduction and oxidation potentials, so that eHOIL < ϵO2/H2O < ϵH+/H2 < ϵLUIL), thus decreasing the photon energy required for splitting of H2O molecule. For C- and Fe-doped TiO2 NTs, some impurity levels lie in the interval between both redox po...