Something to bear in mind, if your frame has internal routing for its gear cables (and/or rear brake cable), is that, depending on how that routing is configured, you may well need the plastic inner cable guide tubing (that hopefully came with the frame/bike) to achieve successful replacement on the road (or anywhere else for that matter).
The tubing threads into and through the frame over the existing inner, before you remove the cable. Once the guide is all the way through, you can remove the existing inner and insert the new one through the tubing+frame, and then remove the guide tubing.
Internal routing has become very popular - and some frames have internal routing which could be impossible to replace inners on while on the road if you don't have the guide tubing (in sufficient length - probably coiled up in pocket or seatpack).