Like already mentioned, you are on right track with new cables
...or at least pull each casing out of the stop, slide it up the cable then add some grease (lightly) to the cable where the casing will be
if the section that loops from the frame to the rear der has a stop attached to the seat stay (part of frame that runs from rear wheel to seatpost), water/dirt/gunk will often run down the cable & into the housing which can lead to trouble - big benefit from cleaning/greasing this section
Cables are important
The shifter is the indexed (digital) part, while the ders are "analog"; the cable transfers shifter movement to the ders ...so if the cables are dirty, worn, binding in casings, etc - it is possible to get poor shifting or gear jumping
Cable Casings are also important as they allow the cable to transfer movement around a curve
If the casings are inflexible or if the liners are worn - it can lead to poor shifting
