Trogtalite CoSe2 nanobuds encapsulated into boron and nitrogen codoped graphene (BCN) nanotubes (CoSe2@BCN-750) are synthesized via a concurrent thermal decomposition and selenization processes. The CoSe2@BCN-750 nanotubes deliver an excellent storage capacity of 580 mA h g-1 at current density of 100 mA g-1 at 100th cycle, as the anode of a sodium ion battery. The CoSe2@BCN-750 nanotubes exhibit a significant rate capability (100-2000 mA g-1 current density) and high stability (almost 98% storage retention after 4000 cycles at large current density of 8000 mA g-1). The reasons for these excellent storage properties are illuminated by theoretical calculations of the relevant models, and various possible Na+ ion storage sites are identified through first-principles calculations. These results demonstrate that the insertion of heteroatoms, B-C, N-C as well as CoSe2, into BCN tubes, enables the observed excellent adsorption energy of Na+ ions in high energy storage devices, which supports the experimental results.